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 += '