From 060c73d431415ddceb5c0a58ae40d43c9c54676e Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Tue, 29 Nov 2022 22:25:02 +0800 Subject: [PATCH] [opt] more default layout --- _config.yml | 16 ++++++++++++++-- _data/widgets.yml | 11 +++++++++++ layout/_partial/sidebar/index.ejs | 10 ++++++++-- layout/index.ejs | 2 +- layout/wiki.ejs | 4 ++-- source/css/_plugins/search/local-search.styl | 4 +--- source/js/search/local-search.js | 2 +- 7 files changed, 38 insertions(+), 11 deletions(-) diff --git a/_config.yml b/_config.yml index 9ce251e..9e04e07 100755 --- a/_config.yml +++ b/_config.yml @@ -25,10 +25,22 @@ sidebar: # about: '[关于](/about/)' # Sidebar widgets widgets: - index: welcome, recent, search, timeline # for home/wiki/categories/tags/archives/404 pages - page: welcome, toc # for pages using 'layout:page' + #### 自动生成的页面 #### + # 主页 + home: search, welcome, recent, timeline # for home + # 博客索引页 + blog_index: search_blog, recent, timeline # for categories/tags/archives + # 文档索引页 + wiki_index: search_docs, recent, timeline # for wiki + # 其它(404) + others: search, welcome, recent, timeline # for 404 and ... + #### 手动创建的页面 #### + # 文章内页 post: toc, ghrepo, search, ghissues # for pages using 'layout:post' + # 文档内页 wiki: search, ghrepo, toc, ghissues, related # for pages using 'layout:wiki' + # 其它 layout:page 的页面 + page: welcome, toc, search # for custom pages using 'layout:page' ######## Index ######## post-index: # 近期发布 分类 标签 归档 and ... diff --git a/_data/widgets.yml b/_data/widgets.yml index 29e7ed9..d0093cf 100644 --- a/_data/widgets.yml +++ b/_data/widgets.yml @@ -5,6 +5,17 @@ search: layout: search filter: auto # auto or 'path' + + +search_blog: + layout: search + filter: /blog/ # auto or 'path' + placeholder: 文章搜索 + +search_docs: + layout: search + filter: /wiki/ # auto or 'path' + placeholder: 文档搜索 ghrepo: layout: ghrepo diff --git a/layout/_partial/sidebar/index.ejs b/layout/_partial/sidebar/index.ejs index cbfd48c..0ecff08 100755 --- a/layout/_partial/sidebar/index.ejs +++ b/layout/_partial/sidebar/index.ejs @@ -14,8 +14,14 @@ if (page.sidebar == undefined) { } else { page.sidebar = theme.sidebar.widgets.wiki; } - } else if (is_home() || ['categories', 'tags', 'archives', 'index', '404', undefined].includes(page.layout)) { - page.sidebar = theme.sidebar.widgets.index; + } else if (is_home()) { + page.sidebar = theme.sidebar.widgets.home; + } 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; } else { diff --git a/layout/index.ejs b/layout/index.ejs index 33c23b4..522f3a9 100755 --- a/layout/index.ejs +++ b/layout/index.ejs @@ -1,6 +1,6 @@ <% if (page.menu_id == undefined) { - if (page.layout === 'index' && page.wiki) { + if (page.layout === 'wiki_index' && page.wiki) { page.menu_id = 'wiki'; } else { page.menu_id = 'post'; diff --git a/layout/wiki.ejs b/layout/wiki.ejs index 7aad4c4..50a63e0 100755 --- a/layout/wiki.ejs +++ b/layout/wiki.ejs @@ -3,7 +3,7 @@ if (page.menu_id == undefined) { page.menu_id = 'wiki'; } if (page.layout == undefined) { - page.layout = 'index'; + page.layout = 'wiki_index'; } if (page.title == undefined) { if (page.tagName) { @@ -21,7 +21,7 @@ function layoutTitle() { } } %> -<% if (page.layout === 'index') { %> +<% if (page.layout === 'wiki_index') { %> <%- partial('index') %> <% } else { %> <% diff --git a/source/css/_plugins/search/local-search.styl b/source/css/_plugins/search/local-search.styl index f5d30fd..1ccde73 100644 --- a/source/css/_plugins/search/local-search.styl +++ b/source/css/_plugins/search/local-search.styl @@ -44,10 +44,8 @@ .search-result-title color: $color-hover .search-result-title - background-image: none color: var(--text-p1) - text-transform: capitalize - font-weight: bold + font-weight: 700 line-height: 1.2 .search-result-content diff --git a/source/js/search/local-search.js b/source/js/search/local-search.js index 91739c6..246c0f6 100644 --- a/source/js/search/local-search.js +++ b/source/js/search/local-search.js @@ -60,7 +60,7 @@ var searchFunc = function(path, filter, searchId, contentId) { if (filter && !data.path.includes(filter)) { return; } - var dataTitle = data.title.trim().toLowerCase(); + var dataTitle = data.title.trim(); var dataTitleLowerCase = dataTitle.toLowerCase(); var dataContent = data.content; var dataContentLowerCase = dataContent.toLowerCase();