From 041084678e43f3a9b4b81ea766794bdf7de59f40 Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Sun, 14 Jan 2024 17:04:00 +0800 Subject: [PATCH] [opt] refactoring --- _config.yml | 31 ++++++++++---------- layout/_partial/main/navbar/breadcrumb.ejs | 9 ------ layout/_partial/main/post_list/post_card.ejs | 13 +------- layout/_partial/sidebar/index.ejs | 6 ++-- layout/archive.ejs | 2 +- scripts/generators/author.js | 1 + 6 files changed, 22 insertions(+), 40 deletions(-) diff --git a/_config.yml b/_config.yml index 76decd5..6f930dc 100755 --- a/_config.yml +++ b/_config.yml @@ -16,7 +16,21 @@ open_graph: enable: true twitter_id: # for open_graph meta -######## head tags ######## + +######## Sidebar ######## +logo: + avatar: '[config.avatar](/about/)' # you can set avatar link in _config.yml or '[https://xxx.png](/about/)' + title: '[config.title](/)' # you can set html tag like: '[](/)' + subtitle: # 文字1 | 文字2(鼠标放上去会切换到文字2) + +menu: + # post: '[btn.blog](/)' + # wiki: '[btn.wiki](/wiki/)' + # friends: '[友链](/friends/)' + # about: '[关于](/about/)' + + +######## Main ######## # 站点主结构树 root: # 主页配置 @@ -57,22 +71,7 @@ root: page: sidebar: toc, search -######## Sidebar ######## -logo: - avatar: '[config.avatar](/about/)' # you can set avatar link in _config.yml or '[https://xxx.png](/about/)' - title: '[config.title](/)' # you can set html tag like: '[](/)' - subtitle: # 文字1 | 文字2(鼠标放上去会切换到文字2) -menu: - # post: '[btn.blog](/)' - # wiki: '[btn.wiki](/wiki/)' - # friends: '[友链](/friends/)' - # about: '[关于](/about/)' - - -######## Main ######## -breadcrumb: - home: home # config.title / config.author / home or custom content ######## Article ######## article: diff --git a/layout/_partial/main/navbar/breadcrumb.ejs b/layout/_partial/main/navbar/breadcrumb.ejs index 89c711d..79925a4 100644 --- a/layout/_partial/main/navbar/breadcrumb.ejs +++ b/layout/_partial/main/navbar/breadcrumb.ejs @@ -5,15 +5,6 @@ function layoutDiv() { return el; } var home_title = __("btn.home"); - if (theme.breadcrumb && theme.breadcrumb.home) { - if (theme.breadcrumb.home === 'config.title') { - home_title = config.title; - } else if (theme.breadcrumb.home === 'config.author') { - home_title = config.author; - } else if (theme.breadcrumb.home !== 'home') { - home_title = theme.breadcrumb.home; - } - } if (page.layout === "post") { var firstCat = ""; if (page.categories && page.categories.length > 0) { diff --git a/layout/_partial/main/post_list/post_card.ejs b/layout/_partial/main/post_list/post_card.ejs index b0adf7a..a17dca3 100755 --- a/layout/_partial/main/post_list/post_card.ejs +++ b/layout/_partial/main/post_list/post_card.ejs @@ -69,18 +69,7 @@ function div_default() { // meta el += '
'; el += ''; - // author - 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 - } - } - if (author) { - el += author.name + ' ' - } + // time el += __("meta.created") + ' ' + ''; el += ''; diff --git a/layout/_partial/sidebar/index.ejs b/layout/_partial/sidebar/index.ejs index 80a2c80..0b06722 100755 --- a/layout/_partial/sidebar/index.ejs +++ b/layout/_partial/sidebar/index.ejs @@ -12,10 +12,12 @@ if (page.sidebar == null) { sidebar = root.wiki.sidebar } else if (page.layout === '404') { sidebar = root.error_page.sidebar - } else if (page.layout === null || page.layout === 'page') { + } else if (page.layout === 'page') { sidebar = root.page.sidebar - } else if (page.layout == 'post') { + } else if (page.layout === 'post') { sidebar = root.post.sidebar + } else if (page.layout == null) { + sidebar = root.page.sidebar } else { sidebar = [] } diff --git a/layout/archive.ejs b/layout/archive.ejs index 05f005b..7af1fab 100755 --- a/layout/archive.ejs +++ b/layout/archive.ejs @@ -13,7 +13,7 @@ function layoutArchiveList() { el += partial('_partial/main/navbar/author_banner') } else { page.title = __('btn.archives') - el += partial('_partial/main/navbar/list_post') + el += partial('_partial/main/navbar/nav_tabs_blog') } el += `
` var years = [] diff --git a/scripts/generators/author.js b/scripts/generators/author.js index 91301dc..8624dd3 100644 --- a/scripts/generators/author.js +++ b/scripts/generators/author.js @@ -15,6 +15,7 @@ hexo.extend.generator.register('author', function (locals) { layout: ['archive'], data: { author: author, + sidebar: root.author.sidebar, menu_id: root.author.menu_id } })