156 lines
5.4 KiB
Plaintext
156 lines
5.4 KiB
Plaintext
<%
|
|
function layoutDiv() {
|
|
var el = '';
|
|
if (page.breadcrumb === false) {
|
|
return el;
|
|
}
|
|
var home_title = __("btn.home");
|
|
if (page.layout === "post") {
|
|
var firstCat = "";
|
|
if (page.categories && page.categories.length > 0) {
|
|
firstCat = page.categories.data[0].name;
|
|
}
|
|
el += '<div class="bread-nav fs12">';
|
|
el += '<div class="left">';
|
|
el += '<div id="breadcrumb">';
|
|
el += '<a class="cap breadcrumb" href="' + url_for(config.root) + '">' + home_title + '</a>';
|
|
el += '<span class="sep"></span>';
|
|
el += '<a class="cap breadcrumb" href="' + url_for(config.index_generator.path) + '">' + __("btn.blog") + '</a>';
|
|
if (page.layout == "post" && page.categories && page.categories.length > 0) {
|
|
el += '<span class="sep"></span>';
|
|
el += list_categories(page.categories, {
|
|
class: "cap breadcrumb",
|
|
show_count: false,
|
|
separator: ' <span class="sep"></span> ',
|
|
style: "none"
|
|
});
|
|
}
|
|
el += '</div>';
|
|
// 作者
|
|
var author = null
|
|
if (theme.authors) {
|
|
if (page.author?.length > 0 && theme.authors[page.author] != null) {
|
|
author = theme.authors[page.author]
|
|
} else {
|
|
author = theme.default_author
|
|
}
|
|
}
|
|
el += '<div id="post-meta">';
|
|
if (author) {
|
|
let link = `<a href="${url_for(author.path)}">${author.name}</a>`
|
|
el += `<span class="author">${__("meta.created_author", link)}</span>`
|
|
} else {
|
|
el += `<span class="author">${__("meta.created")}</span>`
|
|
}
|
|
// 发布日期
|
|
el += `
|
|
<span class="created"><time datetime="${date_xml(page.date)}">${date(page.date, config.date_format)}</time></span>
|
|
`;
|
|
// 更新日期
|
|
el += `
|
|
<span class="updated">${__("symbol.comma") + __("meta.updated")} <time datetime="${date_xml(page.updated)}">${date(page.updated, config.date_format)}</time></span>
|
|
`;
|
|
el += '</div>';
|
|
|
|
el += '</div>';
|
|
el += '</div>';
|
|
} else if (page.topic?.length > 0) {
|
|
el += '<div class="bread-nav fs12">';
|
|
el += '<div class="left">';
|
|
el += '<div id="breadcrumb">';
|
|
var nodes = [];
|
|
// home
|
|
el += '<a class="cap breadcrumb" id="home" href="' + url_for(config.root) + '">' + home_title + '</a>';
|
|
nodes.push('/');
|
|
// menu_id
|
|
el += '<span class="sep"></span>';
|
|
let url = url_for(theme.site_tree.topic.base_dir);
|
|
nodes.push(url);
|
|
el += '<a class="cap breadcrumb" id="menu" href="' + url + '">' + __("btn.topic") + '</a>';
|
|
// 专栏名
|
|
let topicObject = theme.topic.tree[page.topic];
|
|
if (topicObject != null) {
|
|
let url_proj = url_for(topicObject.homepage?.path);
|
|
if (nodes.includes(url_proj) === false) {
|
|
el += '<span class="sep"></span>';
|
|
el += '<a class="cap breadcrumb" id="proj" href="' + url_proj + '">' + (topicObject.name || topicObject.title) + '</a>';
|
|
}
|
|
}
|
|
el += '</div>';
|
|
// 更新日期
|
|
el += '<div id="post-meta">';
|
|
el += `
|
|
<span>${__("meta.updated")} <time datetime="${date_xml(page.updated)}">${date(page.updated, config.date_format)}</time></span>
|
|
`;
|
|
el += '</div>';
|
|
el += '</div>';
|
|
el += '</div>';
|
|
} else if (page.layout === "wiki" && page.wiki?.length > 0) {
|
|
el += '<div class="bread-nav fs12">';
|
|
el += '<div class="left">';
|
|
el += '<div id="breadcrumb">';
|
|
var nodes = [];
|
|
// home
|
|
el += '<a class="cap breadcrumb" id="home" href="' + url_for(config.root) + '">' + home_title + '</a>';
|
|
nodes.push('/');
|
|
// menu_id
|
|
el += '<span class="sep"></span>';
|
|
let url = url_for(theme.site_tree.wiki.base_dir);
|
|
nodes.push(url);
|
|
el += '<a class="cap breadcrumb" id="menu" href="' + url + '">' + __("btn.wiki") + '</a>';
|
|
// 项目名
|
|
const proj = theme.wiki.tree[page.wiki]
|
|
if (proj != null) {
|
|
let url_proj = url_for(proj.homepage?.path);
|
|
if (nodes.includes(url_proj) === false) {
|
|
el += '<span class="sep"></span>';
|
|
el += '<a class="cap breadcrumb" id="proj" href="' + url_proj + '">' + (proj.name || proj.title) + '</a>';
|
|
}
|
|
}
|
|
el += '</div>';
|
|
// 更新日期
|
|
el += '<div id="post-meta">';
|
|
el += `
|
|
<span>${__("meta.updated")} <time datetime="${date_xml(page.updated)}">${date(page.updated, config.date_format)}</time></span>
|
|
`;
|
|
el += '</div>';
|
|
el += '</div>';
|
|
|
|
const repo = page.repo || proj?.repo
|
|
if (repo) {
|
|
el += `
|
|
<div class="right ghrepo stellar-ghinfo-api" api="${theme.api_host.ghapi}/repos/${repo}">
|
|
<a class="repo-link bold" href="https://github.com/${repo}">
|
|
${icon('github:repo')}
|
|
<span type="text">${repo}</span>
|
|
</a>
|
|
<a class="repo-link" href="https://github.com/${repo}/stargazers">
|
|
${icon('github:star')}
|
|
<span type="text" id="stargazers_count">0</span><span>stars</span>
|
|
</a>
|
|
<a class="repo-link" href="https://github.com/${repo}/forks">
|
|
${icon('github:fork')}
|
|
<span type="text" id="forks_count">0</span><span>forks</span>
|
|
</a>
|
|
</div>
|
|
`;
|
|
}
|
|
el += '</div>';
|
|
} else if (page.title) {
|
|
el += `
|
|
<div class="bread-nav fs12">
|
|
<div class="left">
|
|
<div id="breadcrumb">
|
|
<a class="cap breadcrumb" href="${url_for(config.root)}">${home_title}</a>
|
|
<span class="sep"></span>
|
|
<a class="cap breadcrumb" href="${url_for(page.path)}">${page.title}</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
return el;
|
|
}
|
|
%>
|
|
<%- layoutDiv() %>
|