From bc19be406670b7c7b561215aa665c918e1f8a916 Mon Sep 17 00:00:00 2001
From: xaoxuu
Date: Fri, 19 Nov 2021 22:04:14 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BE=A7=E8=BE=B9=E6=A0=8F?=
=?UTF-8?q?=E9=BB=98=E8=AE=A4=E7=BB=84=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
_config.yml | 9 +++++++--
layout/404.ejs | 2 +-
layout/_partial/sidebar/index.ejs | 11 ++++++++---
layout/_partial/sidebar/widgets/toc.ejs | 3 ++-
4 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/_config.yml b/_config.yml
index 00d74d9..686cdd2 100755
--- a/_config.yml
+++ b/_config.yml
@@ -24,9 +24,14 @@ sidebar:
# friends: '[友链](/friends/)'
# about: '[关于](/about/)'
# 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:
# default layout in home/wiki/categories/tags/archives pages
- default_layout: [welcome]
+ # default_layout: [welcome]
# Recent update
recent:
layout: recent
@@ -58,7 +63,7 @@ sidebar:
######## Main ########
breadcrumb:
- home: config.title # config.title / config.author / home or custom content
+ home: home # config.title / config.author / home or custom content
######## Article ########
article:
diff --git a/layout/404.ejs b/layout/404.ejs
index f4b77e7..90cf4cd 100755
--- a/layout/404.ejs
+++ b/layout/404.ejs
@@ -16,6 +16,6 @@ page.robots = 'none';
<%- __('page.error.why') %>
- <%- __('page.error.action') %>
+ <%- __('page.error.action') %>
<%- partial('_partial/plugins/comments/layout') %>
diff --git a/layout/_partial/sidebar/index.ejs b/layout/_partial/sidebar/index.ejs
index ab3828b..65ee1c8 100755
--- a/layout/_partial/sidebar/index.ejs
+++ b/layout/_partial/sidebar/index.ejs
@@ -2,16 +2,21 @@
// 默认组件
if (page.sidebar == undefined) {
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) {
let proj = theme.wiki.projects[page.wiki];
if (proj.sidebar) {
page.sidebar = proj.sidebar;
} 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 {
- page.sidebar = theme.sidebar.widgets.default_layout;
+ console.log('page.layout: ', page.layout);
+ page.sidebar = [];
}
}
function layoutWidgets() {
diff --git a/layout/_partial/sidebar/widgets/toc.ejs b/layout/_partial/sidebar/widgets/toc.ejs
index 2b2b0a9..4a023cb 100644
--- a/layout/_partial/sidebar/widgets/toc.ejs
+++ b/layout/_partial/sidebar/widgets/toc.ejs
@@ -66,7 +66,7 @@ function layoutDiv(fallback) {
el += '