hexo-theme-stellar/layout/_partial/main/navbar/breadcrumb.ejs

76 lines
2.9 KiB
Plaintext
Raw Normal View History

2021-07-04 20:21:31 +08:00
<%
function layoutDiv() {
var el = '';
if (page.breadcrumb === false) {
return el;
}
if (page.layout === "post") {
var firstCat = "";
2021-02-23 21:09:49 +08:00
if (page.categories && page.categories.length > 0) {
firstCat = page.categories.data[0].name;
}
2021-07-26 22:26:46 +08:00
el += '<div class="bread-nav fs12">';
el += '<div id="breadcrumb">';
2021-07-04 20:21:31 +08:00
el += '<a class="cap breadcrumb" href="/">' + __("btn.home") + '</a>';
el += '<span class="sep"></span>';
el += '<a class="cap breadcrumb" href="/">' + __("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>';
// 发布日期
el += '<div id="post-meta">';
el += __("meta.created") + '&nbsp;<time datetime="' + date_xml(page.date) + '">' + date(page.date, config.date_format) + '</time>';
el += '</div>';
2021-07-26 22:26:46 +08:00
el += '</div>';
2021-07-04 20:21:31 +08:00
} else if (page.layout === "wiki" && page.wiki && page.wiki.length > 0) {
2021-07-26 22:26:46 +08:00
el += '<div class="bread-nav fs12">';
el += '<div id="breadcrumb">';
2021-07-04 20:21:31 +08:00
var nodes = [];
// home
el += '<a class="cap breadcrumb" id="home" href="/">' + __("btn.home") + '</a>';
nodes.push('/');
// menu_id
el += '<span class="sep"></span>';
if (page.menu_id && theme.sidebar.menu[page.menu_id] && md_link(theme.sidebar.menu[page.menu_id])) {
let url = url_for(md_link(theme.sidebar.menu[page.menu_id]));
nodes.push(url);
el += '<a class="cap breadcrumb" id="menu" href="' + url + '">' + __(md_text(theme.sidebar.menu[page.menu_id])) + '</a>';
} else {
let url = url_for(config.wiki_dir || "/wiki/");
nodes.push(url);
el += '<a class="cap breadcrumb" id="menu" href="' + url + '">' + __("btn.wiki") + '</a>';
}
// 项目名
2021-07-26 22:26:46 +08:00
let proj = theme.wiki.projects[page.wiki];
let url_proj = url_for(proj.homepage.path);
2021-07-04 20:21:31 +08:00
if (nodes.includes(url_proj) === false) {
el += '<span class="sep"></span>';
el += '<a class="cap breadcrumb" id="proj" href="' + url_proj + '">' + proj.title + '</a>';
}
el += '</div>';
// 更新日期
el += '<div id="post-meta">';
el += __("meta.updated") + '&nbsp;<time datetime="' + date_xml(page.updated) + '">' + date(page.updated, config.date_format) + '</time>';
el += '</div>';
2021-07-26 22:26:46 +08:00
el += '</div>';
} else if (page.title || page.seo_title) {
el += '<div class="bread-nav fs12">';
2021-07-04 20:21:31 +08:00
el += '<div id="breadcrumb">';
el += '<a class="cap breadcrumb" href="/">' + __("btn.home") + '</a>';
el += '<span class="sep"></span>';
el += '<a class="cap breadcrumb" href="' + url_for(page.path) + '">' + (page.title || page.seo_title) + '</a>';
el += '</div>';
2021-07-26 22:26:46 +08:00
el += '</div>';
2021-07-04 20:21:31 +08:00
}
return el;
}
%>
<%- layoutDiv() %>