优化侧边栏默认组件
This commit is contained in:
parent
8f8ce3d91f
commit
bc19be4066
|
@ -24,9 +24,14 @@ sidebar:
|
||||||
# friends: '[友链](/friends/)'
|
# friends: '[友链](/friends/)'
|
||||||
# about: '[关于](/about/)'
|
# about: '[关于](/about/)'
|
||||||
# Sidebar widgets
|
# Sidebar widgets
|
||||||
|
widget_layout:
|
||||||
|
index: [welcome, recent] # for home/wiki/categories/tags/archives/404 pages
|
||||||
|
page: [welcome, toc] # for pages using 'layout:page'
|
||||||
|
post: [toc, repo_info] # for pages using 'layout:post'
|
||||||
|
wiki: [toc, repo_info, wiki_more] # for pages using 'layout:wiki'
|
||||||
widgets:
|
widgets:
|
||||||
# default layout in home/wiki/categories/tags/archives pages
|
# default layout in home/wiki/categories/tags/archives pages
|
||||||
default_layout: [welcome]
|
# default_layout: [welcome]
|
||||||
# Recent update
|
# Recent update
|
||||||
recent:
|
recent:
|
||||||
layout: recent
|
layout: recent
|
||||||
|
@ -58,7 +63,7 @@ sidebar:
|
||||||
|
|
||||||
######## Main ########
|
######## Main ########
|
||||||
breadcrumb:
|
breadcrumb:
|
||||||
home: config.title # config.title / config.author / home or custom content
|
home: home # config.title / config.author / home or custom content
|
||||||
|
|
||||||
######## Article ########
|
######## Article ########
|
||||||
article:
|
article:
|
||||||
|
|
|
@ -16,6 +16,6 @@ page.robots = 'none';
|
||||||
<%- __('page.error.why') %>
|
<%- __('page.error.why') %>
|
||||||
</p>
|
</p>
|
||||||
<br><br>
|
<br><br>
|
||||||
<a class='button theme' id='back' href="/"><%- __('page.error.action') %></a>
|
<a class='button theme' id='back' href="<%- config.root %>"><%- __('page.error.action') %></a>
|
||||||
</article>
|
</article>
|
||||||
<%- partial('_partial/plugins/comments/layout') %>
|
<%- partial('_partial/plugins/comments/layout') %>
|
||||||
|
|
|
@ -2,16 +2,21 @@
|
||||||
// 默认组件
|
// 默认组件
|
||||||
if (page.sidebar == undefined) {
|
if (page.sidebar == undefined) {
|
||||||
if (page.layout == 'post' && page.content) {
|
if (page.layout == 'post' && page.content) {
|
||||||
page.sidebar = ['toc', 'repo_info'];
|
page.sidebar = theme.sidebar.widget_layout.post;
|
||||||
} else if (page.layout == 'wiki' && page.content && page.wiki) {
|
} else if (page.layout == 'wiki' && page.content && page.wiki) {
|
||||||
let proj = theme.wiki.projects[page.wiki];
|
let proj = theme.wiki.projects[page.wiki];
|
||||||
if (proj.sidebar) {
|
if (proj.sidebar) {
|
||||||
page.sidebar = proj.sidebar;
|
page.sidebar = proj.sidebar;
|
||||||
} else {
|
} else {
|
||||||
page.sidebar = ['toc', 'repo_info', 'wiki_more'];
|
page.sidebar = theme.sidebar.widget_layout.wiki;
|
||||||
}
|
}
|
||||||
|
} else if (is_home() || ['categories', 'tags', 'archives', 'index', '404'].includes(page.layout)) {
|
||||||
|
page.sidebar = theme.sidebar.widget_layout.index;
|
||||||
|
} else if (page.layout == 'page') {
|
||||||
|
page.sidebar = theme.sidebar.widget_layout.page;
|
||||||
} else {
|
} else {
|
||||||
page.sidebar = theme.sidebar.widgets.default_layout;
|
console.log('page.layout: ', page.layout);
|
||||||
|
page.sidebar = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function layoutWidgets() {
|
function layoutWidgets() {
|
||||||
|
|
|
@ -66,7 +66,7 @@ function layoutDiv(fallback) {
|
||||||
el += '<div class="widget-wrap ' + type + '" id="toc">';
|
el += '<div class="widget-wrap ' + type + '" id="toc">';
|
||||||
if (page.layout !== 'wiki') {
|
if (page.layout !== 'wiki') {
|
||||||
// post 布局
|
// post 布局
|
||||||
el += layoutTocHeader(page.toc_title || __("meta.toc"));
|
el += layoutTocHeader(page.toc_title);
|
||||||
el += '<div class="widget-body fs14">';
|
el += '<div class="widget-body fs14">';
|
||||||
el += '<div class="doc-tree active">';
|
el += '<div class="doc-tree active">';
|
||||||
el += layoutToc();
|
el += layoutToc();
|
||||||
|
@ -84,6 +84,7 @@ function layoutDiv(fallback) {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// 单 section
|
// 单 section
|
||||||
|
el += layoutTocHeader(page.toc_title);
|
||||||
el += '<div class="widget-body fs14">';
|
el += '<div class="widget-body fs14">';
|
||||||
el += layoutDocTree(proj.pages);
|
el += layoutDocTree(proj.pages);
|
||||||
el += '</div>';
|
el += '</div>';
|
||||||
|
|
Loading…
Reference in New Issue