diff --git a/_config.yml b/_config.yml index 344ae09..76decd5 100755 --- a/_config.yml +++ b/_config.yml @@ -16,48 +16,58 @@ open_graph: enable: true twitter_id: # for open_graph meta -# 只影响生成的页面路径,不影响配置文件命名规则 -base_dir: - wiki: wiki - topic: topic - author: author +######## head tags ######## +# 站点主结构树 +root: + # 主页配置 + home: + sidebar: search, recent, timeline + # 博客配置 + blog: + base_dir: blog # 只影响自动生成的页面路径 + menu_id: post # 未在 front-matter 中指定 menu_id 时,layout 为 post 的页面默认使用这里配置的 menu_id + sidebar: search_blog, recent, timeline # for categories/tags/archives + nav_tabs: # 近期发布 分类 标签 专栏 归档 and ... + # '朋友文章': /friends/rss/ + # 博客文章配置 + post: + menu_id: post # 未在 front-matter 中指定 menu_id 时,layout 为 post 的页面默认使用这里配置的 menu_id + sidebar: search_blog, toc, related, ghrepo, ghissues # for pages using 'layout:post' + # 博客专栏配置 + topic: + base_dir: topic # 只影响自动生成的页面路径 + menu_id: post # 未在 front-matter 中指定 menu_id 时,layout 为 topic 的页面默认使用这里配置的 menu_id + sidebar: search_blog, toc, related # for topic + # wiki配置 + wiki: + base_dir: wiki # 只影响自动生成的页面路径 + menu_id: wiki # 未在 front-matter 中指定 menu_id 时,layout 为 wiki 的页面默认使用这里配置的 menu_id + sidebar: search_docs, ghissues, related, recent, timeline # for wiki + # 作者信息配置 + author: + base_dir: author # 只影响自动生成的页面路径 + menu_id: post + sidebar: search_blog, recent, timeline + # 错误页配置 + error_page: + menu_id: post + '404': '/404.html' + sidebar: search, recent, timeline + # 其它自定义页面配置 layout: page + page: + sidebar: toc, search ######## Sidebar ######## -sidebar: - logo: +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: '[](/)' - menu: - # post: '[btn.blog](/)' - # wiki: '[btn.wiki](/wiki/)' - # friends: '[友链](/friends/)' - # about: '[关于](/about/)' - # Sidebar widgets - widgets: - #### 自动生成的页面 #### - # 主页 - home: search, recent, timeline # for home - # 博客索引页 - blog_index: search_blog, recent, timeline # for categories/tags/archives - # 文档索引页 - wiki_index: search_docs, recent, timeline # for wiki - # 专栏索引页 - index_topic: search_blog, recent, timeline # for topic - # 其它(404) - others: search, recent, timeline # for 404 and ... - #### 手动创建的页面 #### - # 文章内页 - post: search_blog, toc, related, ghrepo, ghissues # for pages using 'layout:post' - # 专栏内页 - topic: search_blog, toc, related # for pages using 'layout:wiki' - # 文档内页 - wiki: search_blog, toc, ghissues, related # for pages using 'layout:wiki' - # 其它 layout:page 的页面 - page: toc, search # for custom pages using 'layout:page' + subtitle: # 文字1 | 文字2(鼠标放上去会切换到文字2) -######## Index ######## -post-index: # 近期发布 分类 标签 归档 and ... - # '朋友文章': /friends/rss/ +menu: + # post: '[btn.blog](/)' + # wiki: '[btn.wiki](/wiki/)' + # friends: '[友链](/friends/)' + # about: '[关于](/about/)' ######## Main ######## diff --git a/layout/404.ejs b/layout/404.ejs index 36004c4..283bddf 100755 --- a/layout/404.ejs +++ b/layout/404.ejs @@ -1,6 +1,4 @@ <% -page.menu_id = '404'; -page.layout = '404'; page.comment_title = ''; page.header = 'auto'; page.robots = 'none'; diff --git a/layout/_partial/main/article/read_next.ejs b/layout/_partial/main/article/read_next.ejs index 8067ee1..4b87957 100644 --- a/layout/_partial/main/article/read_next.ejs +++ b/layout/_partial/main/article/read_next.ejs @@ -4,25 +4,9 @@ function layoutDiv() { var title = __('meta.read_next') title_prev = __('meta.newer') title_next = __('meta.older') - if (page.layout === 'post') { + if (page.layout === 'post' || page.layout === 'topic') { prev = page.prev next = page.next - } else if (page.layout === 'topic' && page.topic?.length > 0) { - const topicObject = theme.topic.tree[page.topic] - if (topicObject) { - const current_page_date = topicObject.pages.filter(p => p.path == page.path)[0].date - for (let p of topicObject.pages) { - if (p.date > current_page_date) { - if (prev == undefined || p.date < prev.date) { - prev = p - } - } else if (p.date < current_page_date) { - if (next == undefined || p.date > next.date) { - next = p - } - } - } - } } else if (page.layout === 'wiki' && page.wiki?.length > 0) { var title_prev = __('meta.prev'); var title_next = __('meta.next'); diff --git a/layout/_partial/main/navbar/breadcrumb.ejs b/layout/_partial/main/navbar/breadcrumb.ejs index 34a04db..89c711d 100644 --- a/layout/_partial/main/navbar/breadcrumb.ejs +++ b/layout/_partial/main/navbar/breadcrumb.ejs @@ -73,7 +73,7 @@ function layoutDiv() { nodes.push('/'); // menu_id el += ''; - let url = url_for(theme.base_dir.topic); + let url = url_for(theme.root.topic.base_dir); nodes.push(url); el += '' + __("btn.topic") + ''; // 专栏名 @@ -104,12 +104,12 @@ function layoutDiv() { nodes.push('/'); // menu_id el += ''; - 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])); + if (page.menu_id && theme.menu[page.menu_id] && md_link(theme.menu[page.menu_id])) { + let url = url_for(md_link(theme.menu[page.menu_id])); nodes.push(url); - el += '' + __(md_text(theme.sidebar.menu[page.menu_id])) + ''; + el += '' + __(md_text(theme.menu[page.menu_id])) + ''; } else { - let url = url_for(config.wiki_dir || "/wiki/"); + let url = url_for(theme.root.wiki.base_dir); nodes.push(url); el += '' + __("btn.wiki") + ''; } diff --git a/layout/_partial/main/navbar/list_post.ejs b/layout/_partial/main/navbar/nav_tabs_blog.ejs similarity index 74% rename from layout/_partial/main/navbar/list_post.ejs rename to layout/_partial/main/navbar/nav_tabs_blog.ejs index 715fccd..fcf766b 100644 --- a/layout/_partial/main/navbar/list_post.ejs +++ b/layout/_partial/main/navbar/nav_tabs_blog.ejs @@ -29,6 +29,14 @@ function layoutDiv() { } } + if (theme.topic?.publish_list?.length > 0) { + if (page.layout == 'index_topic') { + el += '' + __("btn.topic") + ''; + } else { + el += '' + __("btn.topic") + ''; + } + } + if (site.posts && site.posts.length > 0) { if (is_archive()) { el += '' + __("btn.archives") + ''; @@ -36,23 +44,16 @@ function layoutDiv() { el += '' + __("btn.archives") + ''; } } - if (theme.topic?.publish_list?.length > 0) { - if (page.layout == 'index_topic') { - el += '' + __("btn.topic") + ''; - } else { - el += '' + __("btn.topic") + ''; - } - } - if (theme['post-index']) { - const obj = theme['post-index']; - for (let key of Object.keys(obj)) { + const { nav_tabs } = theme.root.blog + if (nav_tabs) { + for (let key of Object.keys(nav_tabs)) { // 当 page 的末尾为 index.html 或者处于该 page 的某个子页面时也应该匹配 - // if (full_url_for(page.path) == full_url_for(obj[key])) { - if (full_url_for(page.path).startsWith(full_url_for(obj[key]))){ - el += '' + key + ''; + // if (full_url_for(page.path) == full_url_for(nav_tabs[key])) { + if (full_url_for(page.path).startsWith(full_url_for(nav_tabs[key]))){ + el += '' + key + ''; } else { - el += '' + key + ''; + el += '' + key + ''; } } } diff --git a/layout/_partial/main/navbar/list_wiki.ejs b/layout/_partial/main/navbar/nav_tabs_wiki.ejs similarity index 54% rename from layout/_partial/main/navbar/list_wiki.ejs rename to layout/_partial/main/navbar/nav_tabs_wiki.ejs index e2a0ae0..e477203 100644 --- a/layout/_partial/main/navbar/list_wiki.ejs +++ b/layout/_partial/main/navbar/nav_tabs_wiki.ejs @@ -8,7 +8,7 @@ function layoutDiv() { if (page.filter === false) { el += ' class="active"'; } - el += ' href="' + url_for(config.wiki_dir || "/wiki/") + '">' + __("btn.all_wiki") + ''; + el += ' href="' + url_for(theme.root.wiki.base_dir) + '">' + __("btn.all_wiki") + ''; el += ''; // 项目分类 const { shelf, all_tags } = theme.wiki; @@ -24,6 +24,20 @@ function layoutDiv() { el += ''; } } + + const { nav_tabs } = theme.root.wiki + if (nav_tabs) { + for (let key of Object.keys(nav_tabs)) { + // 当 page 的末尾为 index.html 或者处于该 page 的某个子页面时也应该匹配 + // if (full_url_for(page.path) == full_url_for(nav_tabs[key])) { + if (full_url_for(page.path).startsWith(full_url_for(nav_tabs[key]))){ + el += '' + key + ''; + } else { + el += '' + key + ''; + } + } + } + el += ''; el += ''; return el; diff --git a/layout/_partial/sidebar/header.ejs b/layout/_partial/sidebar/header.ejs index e661704..cf8613a 100644 --- a/layout/_partial/sidebar/header.ejs +++ b/layout/_partial/sidebar/header.ejs @@ -32,19 +32,18 @@ function layoutDiv() { el += '">'; el += '
'; - if (md_text(theme.sidebar.logo.avatar)) { - el += ''; + if (md_text(theme.logo.avatar)) { + el += ''; if (theme.style.animated_avatar.animate) { el += '
'; } - el += ''; + el += ''; el += '
'; } - let main = md_text(theme.sidebar.logo.title); + let main = md_text(theme.logo.title); if (main) { - let url = md_link(theme.sidebar.logo.title); - let sub = config.subtitle; - el += layoutTitle(main, url, sub); + let url = md_link(theme.logo.title); + el += layoutTitle(main, url, theme.logo.subtitle); } el += '
'; diff --git a/layout/_partial/sidebar/index.ejs b/layout/_partial/sidebar/index.ejs index b30ed5e..80a2c80 100755 --- a/layout/_partial/sidebar/index.ejs +++ b/layout/_partial/sidebar/index.ejs @@ -1,36 +1,33 @@ <% -// 默认组件 -if (page.sidebar == undefined) { - if (page.layout == 'post' && page.content) { - page.sidebar = theme.sidebar.widgets.post; - } else if (page.layout == 'wiki' && page.wiki) { - let proj = theme.wiki.tree[page.wiki]; - if (proj?.sidebar) { - page.sidebar = proj.sidebar; - } else { - page.sidebar = theme.sidebar.widgets.wiki; - } - } else if (page.layout === 'topic') { - if (page.topic && theme.topic?.tree[page.topic]?.sidebar) { - page.sidebar = theme.topic.tree[page.topic].sidebar; - } else { - page.sidebar = theme.sidebar.widgets.topic; - } - } else if (page.layout === 'index_topic') { - page.sidebar = theme.sidebar.widgets.index_topic - } else if (is_home()) { - page.sidebar = theme.sidebar.widgets.home; +if (page.sidebar == null) { + const root = theme.root + var sidebar + if (is_home()) { + sidebar = root.home.sidebar } else if (is_category() || is_tag() || is_archive() || ['categories', 'tags', 'archives'].includes(page.layout)) { - page.sidebar = theme.sidebar.widgets.blog_index; - } else if (['wiki_index'].includes(page.layout)) { - page.sidebar = theme.sidebar.widgets.wiki_index; - } else if (['404', undefined].includes(page.layout)) { - page.sidebar = theme.sidebar.widgets.others; - } else if (page.layout == 'page') { - page.sidebar = theme.sidebar.widgets.page; + sidebar = root.blog.sidebar + } else if (page.layout === 'index_topic' || page.layout === 'topic') { + sidebar = root.topic.sidebar + } else if (page.layout === 'index_wiki' || page.layout === 'wiki') { + sidebar = root.wiki.sidebar + } else if (page.layout === '404') { + sidebar = root.error_page.sidebar + } else if (page.layout === null || page.layout === 'page') { + sidebar = root.page.sidebar + } else if (page.layout == 'post') { + sidebar = root.post.sidebar } else { - page.sidebar = []; + sidebar = [] } + + if (page.layout === 'topic' && page.topic && theme.topic?.tree[page.topic]?.sidebar) { + sidebar = theme.topic.tree[page.topic].sidebar + } + if (page.layout == 'wiki' && page.wiki && theme.wiki?.tree[page.wiki]?.sidebar) { + sidebar = theme.wiki.tree[page.wiki].sidebar + } + + page.sidebar = sidebar } // parse array string @@ -55,25 +52,25 @@ function layoutTitle(main, url, sub) { } function layoutWidgets() { var el = ''; + var proj; + if (page.layout === 'wiki' && page.wiki) { + proj = theme.wiki.tree[page.wiki]; + } el += '
'; if (page.layout == 'wiki' && proj && page.menu_id == 'wiki') { el += '
'; // all products - el += ''; + el += ''; el += ''; el += __('btn.all_wiki'); el += ''; // this product - var proj; - if (page.layout === 'wiki' && page.wiki) { - proj = theme.wiki.tree[page.wiki]; - } if (proj == undefined) { // 如果没有项目名,则使用menu中显示的名字 - if (page.menu_id && theme.sidebar.menu[page.menu_id] && md_link(theme.sidebar.menu[page.menu_id])) { + if (page.menu_id && theme.menu[page.menu_id] && md_link(theme.menu[page.menu_id])) { proj = { - path: md_link(theme.sidebar.menu[page.menu_id]), - wiki: __(md_text(theme.sidebar.menu[page.menu_id])) + path: md_link(theme.menu[page.menu_id]), + wiki: __(md_text(theme.menu[page.menu_id])) }; } } @@ -142,6 +139,7 @@ function layoutFooterDiv() { return ''; } } + %> <% if (page.header == undefined || page.header == 'left' || page.header == 'auto') { %> <%- partial('header', {where: 'sidebar'}) %> diff --git a/layout/_partial/sidebar/menu.ejs b/layout/_partial/sidebar/menu.ejs index 7896983..52fde0e 100644 --- a/layout/_partial/sidebar/menu.ejs +++ b/layout/_partial/sidebar/menu.ejs @@ -6,8 +6,8 @@ function layoutDiv() { el += ' mobile-hidden'; } el += '">'; - for (let id of Object.keys(theme.sidebar.menu)) { - let item = theme.sidebar.menu[id]; + for (let id of Object.keys(theme.menu)) { + let item = theme.menu[id]; if (item == undefined || item.length == 0) { continue; } diff --git a/layout/_partial/widgets/related.ejs b/layout/_partial/widgets/related.ejs index 6733ebe..4667d7a 100644 --- a/layout/_partial/widgets/related.ejs +++ b/layout/_partial/widgets/related.ejs @@ -1,25 +1,4 @@ <% -function relatedPosts() { - const { categories } = page; - if (categories.length == 0) { - return '' - } - const relatedItem = categories.data[0] - var el = '' - el += `` - el += `
` - el += `${__('btn.topic') + __('symbol.colon') + relatedItem.name}` - el += `
` - el += `` - el += `
` - return el -} function relatedPostsInTopic() { if (page.topic?.length == 0) { return '' @@ -74,8 +53,6 @@ function relatedWiki() { function layoutDiv() { if (page.layout == 'wiki') { return relatedWiki() - } else if (page.layout == 'post') { - return relatedPosts() } else if (page.layout == 'topic') { return relatedPostsInTopic() } diff --git a/layout/categories.ejs b/layout/categories.ejs index 3b6dd7d..d275f98 100755 --- a/layout/categories.ejs +++ b/layout/categories.ejs @@ -7,7 +7,7 @@ if (page.menu_id == undefined) { <% if (site.categories.length) { %> <% page.title = __('btn.categories'); %> <% page.layout = 'categories'; %> - <%- partial('_partial/main/navbar/list_post') %> + <%- partial('_partial/main/navbar/nav_tabs_blog') %>
<% site.categories.sort('path').each(function(category){ %> diff --git a/layout/index.ejs b/layout/index.ejs index fa33141..6fdba21 100755 --- a/layout/index.ejs +++ b/layout/index.ejs @@ -1,10 +1,6 @@ <% if (page.menu_id == undefined) { - if (page.layout === 'wiki_index' && page.wiki) { - page.menu_id = 'wiki'; - } else { - page.menu_id = 'post'; - } + page.menu_id = 'post'; } if (page.title && page.wiki) { page.robots = 'noindex,follow'; @@ -48,42 +44,10 @@ function layout_post_list(partial) { return el; } -function layout_wiki_list(partial) { - var el = ''; - const { shelf, tree } = theme.wiki; - for (let pid of shelf) { - let proj = tree[pid]; - if (proj == null) { - continue; - } - if (proj.pages == undefined || proj.pages.length === 0) { - continue; - } - if (page.filter === false) { - // wikiList - el += '
'; - el += layout_post_card('wiki', proj.homepage, partial(proj)); - el += '
'; - } else if (proj.tags && proj.tags.includes(page.tagName) === true) { - // filtered wikiList - el += '
'; - el += layout_post_card('wiki', proj.homepage, partial(proj)); - el += '
'; - } - } - return el; -} %> -<% if (page.menu_id === 'post') { %> - <%- partial('_partial/main/navbar/list_post') %> - <%- layout_post_list(function(post){ - return partial('_partial/main/post_list/post_card', {post: post}) - }) %> - <%- partial('_partial/main/post_list/paginator') %> -<% } else if (page.menu_id === 'wiki') { %> - <%- partial('_partial/main/navbar/list_wiki') %> - <%- layout_wiki_list(function(proj){ - return partial('_partial/main/post_list/wiki_card', {proj: proj}) - }) %> -<% } %> +<%- partial('_partial/main/navbar/nav_tabs_blog') %> +<%- layout_post_list(function(post){ + return partial('_partial/main/post_list/post_card', {post: post}) +}) %> +<%- partial('_partial/main/post_list/paginator') %> \ No newline at end of file diff --git a/layout/index_topic.ejs b/layout/index_topic.ejs index ca776e1..d9857fc 100644 --- a/layout/index_topic.ejs +++ b/layout/index_topic.ejs @@ -1,12 +1,4 @@ <% -if (page.menu_id == undefined) { - if (page.layout === 'wiki_topic' && page.topic) { - page.menu_id = 'blog' - } else { - page.menu_id = 'post' - } -} - function layout_topic_list(partial) { var el = '' const { publish_list, tree } = theme.topic @@ -25,7 +17,7 @@ function layout_topic_list(partial) { } function layoutDiv() { var el = '' - el += partial('_partial/main/navbar/list_post') + el += partial('_partial/main/navbar/nav_tabs_blog') el += layout_topic_list(function(topic) { return partial('_partial/main/post_list/topic_card', {topic: topic}) }) diff --git a/layout/index_wiki.ejs b/layout/index_wiki.ejs new file mode 100644 index 0000000..1314772 --- /dev/null +++ b/layout/index_wiki.ejs @@ -0,0 +1,42 @@ +<% +function layout_wiki_list(partial) { + var el = '' + const { shelf, tree } = theme.wiki + for (let pid of shelf) { + let proj = tree[pid] + if (proj == null) { + continue + } + if (proj.pages == undefined || proj.pages.length === 0) { + continue + } + if (page.filter === false) { + // wikiList + el += `
` + el += `` + el += partial(proj) + el += `` + el += `
` + } else if (proj.tags && proj.tags.includes(page.tagName) === true) { + // filtered wikiList + el += `
` + el += `` + el += partial(proj) + el += `` + el += `
` + } + } + return el +} + +function layoutDiv() { + var el = '' + el += partial('_partial/main/navbar/nav_tabs_wiki') + el += layout_wiki_list(function(proj) { + return partial('_partial/main/post_list/wiki_card', {proj: proj}) + }) + return el +} +%> + +<%- layoutDiv() %> \ No newline at end of file diff --git a/layout/page.ejs b/layout/page.ejs index da2b84e..562cf7f 100755 --- a/layout/page.ejs +++ b/layout/page.ejs @@ -9,8 +9,8 @@ function layoutTitle() { } function layoutDiv() { var el = ''; - if (page.post_list) { - el += partial('_partial/main/navbar/list_post'); + if (page.nav_tabs) { + el += partial('_partial/main/navbar/nav_tabs_blog'); } if (page.h1 || page.title || (page.content && page.content.length > 0)) { el += partial('_partial/main/navbar/breadcrumb'); diff --git a/layout/tags.ejs b/layout/tags.ejs index 078d7e8..5a2b9e2 100755 --- a/layout/tags.ejs +++ b/layout/tags.ejs @@ -7,7 +7,7 @@ if (page.menu_id == undefined) { <% if (site.tags.length) { %> <% page.title = __('btn.tags'); %> <% page.layout = 'tags'; %> - <%- partial('_partial/main/navbar/list_post') %> + <%- partial('_partial/main/navbar/nav_tabs_blog') %>
<% site.tags.sort('length', -1).each(function(tag){ %> diff --git a/layout/topic.ejs b/layout/topic.ejs index f6fb264..6d2f135 100644 --- a/layout/topic.ejs +++ b/layout/topic.ejs @@ -2,11 +2,8 @@ if (page.menu_id == undefined) { page.menu_id = 'post' } -if (page.layout == undefined) { - page.layout = 'index_topic' -} if (page.title == undefined) { - page.title = __('btn.wiki') + page.title = __('btn.topic') } function layoutTitle() { const title = page.h1 != null ? page.h1 : page.title; @@ -17,23 +14,15 @@ function layoutTitle() { } } %> -<% if (page.layout === 'index_topic') { %> - <%- partial('index') %> -<% } else { %> - <% - if (page.header == undefined) { - page.header = 'auto'; - } - %> - <%- partial('_partial/main/navbar/breadcrumb') %> -
<%- scrollreveal() %>'> - <%- layoutTitle() %> - <%- markdown(page.content) %> - <% if (theme.plugins.tianli_gpt.enable && ['all', 'topic'].includes(theme.plugins.tianli_gpt.field)) { %> - <%- partial('_partial/plugins/ai/tianli_gpt') %> - <% } %> - <%- partial('_partial/main/article/article_footer') %> -
- <%- partial('_partial/main/article/read_next') %> - <%- partial('_partial/plugins/comments/layout') %> + +<%- partial('_partial/main/navbar/breadcrumb') %> +
<%- scrollreveal() %>'> +<%- layoutTitle() %> +<%- markdown(page.content) %> +<% if (theme.plugins.tianli_gpt.enable && ['all', 'topic'].includes(theme.plugins.tianli_gpt.field)) { %> +<%- partial('_partial/plugins/ai/tianli_gpt') %> <% } %> +<%- partial('_partial/main/article/article_footer') %> +
+<%- partial('_partial/main/article/read_next') %> +<%- partial('_partial/plugins/comments/layout') %> \ No newline at end of file diff --git a/layout/wiki.ejs b/layout/wiki.ejs index c7ead00..2cda033 100755 --- a/layout/wiki.ejs +++ b/layout/wiki.ejs @@ -2,9 +2,6 @@ if (page.menu_id == undefined) { page.menu_id = 'wiki'; } -if (page.layout == undefined) { - page.layout = 'wiki_index'; -} if (page.title == undefined) { if (page.tagName) { page.title = page.tagName; @@ -21,23 +18,15 @@ function layoutTitle() { } } %> -<% if (page.layout === 'wiki_index') { %> - <%- partial('index') %> -<% } else { %> - <% - if (page.header == undefined) { - page.header = 'auto'; - } - %> - <%- partial('_partial/main/navbar/breadcrumb') %> -
<%- scrollreveal() %>'> - <%- layoutTitle() %> - <%- page.content %> - <% if (theme.plugins.tianli_gpt.enable && ['all', 'wiki'].includes(theme.plugins.tianli_gpt.field)) { %> - <%- partial('_partial/plugins/ai/tianli_gpt') %> - <% } %> - <%- partial('_partial/main/article/article_footer') %> -
- <%- partial('_partial/main/article/read_next') %> - <%- partial('_partial/plugins/comments/layout') %> + +<%- partial('_partial/main/navbar/breadcrumb') %> +
<%- scrollreveal() %>'> +<%- layoutTitle() %> +<%- page.content %> +<% if (theme.plugins.tianli_gpt.enable && ['all', 'wiki'].includes(theme.plugins.tianli_gpt.field)) { %> +<%- partial('_partial/plugins/ai/tianli_gpt') %> <% } %> +<%- partial('_partial/main/article/article_footer') %> +
+<%- partial('_partial/main/article/read_next') %> +<%- partial('_partial/plugins/comments/layout') %> \ No newline at end of file diff --git a/scripts/events/lib/authors.js b/scripts/events/lib/authors.js index d776fd8..e9857ef 100644 --- a/scripts/events/lib/authors.js +++ b/scripts/events/lib/authors.js @@ -6,7 +6,7 @@ module.exports = ctx => { var authors = ctx.locals.get('data').authors || {} - let basePath = ctx.config.author_dir || 'author' + let basePath = ctx.theme.config.root.author.base_dir // url for (let key of Object.keys(authors)) { let author = authors[key] diff --git a/scripts/events/lib/config.js b/scripts/events/lib/config.js index f7fcd13..8fbcbd5 100644 --- a/scripts/events/lib/config.js +++ b/scripts/events/lib/config.js @@ -56,8 +56,8 @@ module.exports = hexo => { hexo.theme.config.data['widgets'] = widgets; // default menu - if (hexo.theme.config.sidebar.menu == undefined) { - hexo.theme.config.sidebar.menu = []; + if (hexo.theme.config.menu == undefined) { + hexo.theme.config.menu = []; } }; diff --git a/scripts/events/lib/doc_tree.js b/scripts/events/lib/doc_tree.js index c95b113..0386d26 100644 --- a/scripts/events/lib/doc_tree.js +++ b/scripts/events/lib/doc_tree.js @@ -177,7 +177,7 @@ module.exports = ctx => { } all_tags[tag_name] = { name: tag_name, - path: (ctx.config.wiki_dir || 'wiki') + '/tags/' + tag_name + '/index.html', + path: (ctx.theme.config.root.wiki.base_dir) + '/tags/' + tag_name + '/index.html', items: items } }) diff --git a/scripts/generators/404.js b/scripts/generators/404.js index 942532a..294042c 100644 --- a/scripts/generators/404.js +++ b/scripts/generators/404.js @@ -3,8 +3,13 @@ */ hexo.extend.generator.register('404', function (locals) { + const { root } = hexo.theme.config return { - path: '/404.html', - layout: ['404'] + path: root.error_page['404'], + layout: ['404'], + data: { + layout: '404', + menu_id: root.error_page.menu_id + } } -}); \ No newline at end of file +}) \ No newline at end of file diff --git a/scripts/generators/author.js b/scripts/generators/author.js index 0af80c0..91301dc 100644 --- a/scripts/generators/author.js +++ b/scripts/generators/author.js @@ -3,7 +3,7 @@ */ hexo.extend.generator.register('author', function (locals) { - const { authors } = hexo.theme.config + const { root, authors } = hexo.theme.config var pages = [] for (let key of Object.keys(authors)) { const author = authors[key] @@ -14,7 +14,8 @@ hexo.extend.generator.register('author', function (locals) { path: author.path, layout: ['archive'], data: { - 'author': author + author: author, + menu_id: root.author.menu_id } }) } diff --git a/scripts/generators/categories.js b/scripts/generators/categories.js index 2d4a018..bb8dac5 100644 --- a/scripts/generators/categories.js +++ b/scripts/generators/categories.js @@ -6,10 +6,10 @@ hexo.extend.generator.register('categories', function (locals) { if (locals.categories && locals.categories.length > 0) { return { path: hexo.config.category_dir + '/index.html', - data: locals.posts, - layout: ['categories'] + layout: ['categories'], + data: locals.posts } } else { - return {}; + return {} } -}); +}) diff --git a/scripts/generators/tags.js b/scripts/generators/tags.js index 40a07b8..eb1cd2a 100644 --- a/scripts/generators/tags.js +++ b/scripts/generators/tags.js @@ -6,10 +6,10 @@ hexo.extend.generator.register('tags', function (locals) { if (locals.tags && locals.tags.length > 0) { return { path: hexo.config.tag_dir + '/index.html', - data: locals.posts, - layout: ['tags'] + layout: ['tags'], + data: locals.posts } } else { - return {}; + return {} } -}); +}) diff --git a/scripts/generators/topic.js b/scripts/generators/topic.js index e1f7777..380d659 100644 --- a/scripts/generators/topic.js +++ b/scripts/generators/topic.js @@ -3,18 +3,19 @@ */ hexo.extend.generator.register('topic', function (locals) { - const { topic } = hexo.theme.config + const { root, topic } = hexo.theme.config const topicIdList = Object.keys(topic.tree) if (topicIdList.length == 0) { return {} } var ret = [] ret.push({ - path: (hexo.theme.config.base_dir.topic) + '/index.html', + path: root.topic.base_dir + '/index.html', + layout: ['index_topic'], data: { - layout: 'index_topic' - }, - layout: ['index_topic'] + layout: 'index_topic', + menu_id: root.topic.menu_id + } }) return ret }) diff --git a/scripts/generators/wiki.js b/scripts/generators/wiki.js index 29ecfa8..94f2499 100644 --- a/scripts/generators/wiki.js +++ b/scripts/generators/wiki.js @@ -3,34 +3,35 @@ */ hexo.extend.generator.register('wiki', function (locals) { - var hasWiki = false; - locals.pages.forEach((page, i) => { - if (page.layout == 'wiki') { - hasWiki = true; - } - }); - if (hasWiki) { - var ret = []; - ret.push({ - path: (hexo.config.wiki_dir || 'wiki') + '/index.html', - data: {'filter': false}, - layout: ['wiki'] - }); - if (hexo.theme.config.wiki && hexo.theme.config.wiki.all_tags) { - for (let id of Object.keys(hexo.theme.config.wiki.all_tags)) { - let tag = hexo.theme.config.wiki.all_tags[id]; - ret.push({ - path: tag.path, - data: { - 'filter': true, - 'tagName': tag.name - }, - layout: ['wiki'] - }); - } - } - return ret; - } else { - return {}; + const { root, wiki } = hexo.theme.config + const wikiIdList = Object.keys(wiki.tree) + if (wikiIdList.length == 0) { + return {} } -}); + var ret = [] + ret.push({ + path: root.wiki.base_dir + '/index.html', + layout: ['index_wiki'], + data: { + layout: 'index_wiki', + menu_id: root.wiki.menu_id, + filter: false + } + }) + if (wiki.all_tags) { + for (let id of Object.keys(wiki.all_tags)) { + let tag = wiki.all_tags[id] + ret.push({ + path: tag.path, + layout: ['index_wiki'], + data: { + layout: 'index_wiki', + menu_id: root.wiki.menu_id, + filter: true, + tagName: tag.name + } + }) + } + } + return ret +}) diff --git a/scripts/helpers/parse_config.js b/scripts/helpers/parse_config.js index 50e48f4..afdac5a 100644 --- a/scripts/helpers/parse_config.js +++ b/scripts/helpers/parse_config.js @@ -1,6 +1,6 @@ /** - * md_link(theme.sidebar.menu['home']) is '/' - * md_text(theme.sidebar.menu['home']) is 'Home' + * md_link(theme.menu['home']) is '/' + * md_text(theme.menu['home']) is 'Home' */ 'use strict';