From 145272ff15e6d7c3f1542d563e4e38ed303e6947 Mon Sep 17 00:00:00 2001 From: XPoet Date: Fri, 11 Sep 2020 15:06:38 +0800 Subject: [PATCH] pref: perfect configuration & optimize style --- _config.yml | 123 +++++++++++++++++------- layout/_partial/article-meta-info.ejs | 4 +- layout/_partial/footer.ejs | 8 +- layout/_partial/head.ejs | 4 +- layout/_partial/scripts.ejs | 4 +- layout/home-content.ejs | 15 +-- layout/page.ejs | 3 - source/css/layout/_partial/tools.styl | 3 + source/css/layout/common/variables.styl | 20 ++-- source/css/layout/page.styl | 7 ++ source/js/header-shrink.js | 37 +++---- source/js/{post.js => post-toc.js} | 0 12 files changed, 143 insertions(+), 85 deletions(-) rename source/js/{post.js => post-toc.js} (100%) diff --git a/_config.yml b/_config.yml index 3195f0a..5eea877 100644 --- a/_config.yml +++ b/_config.yml @@ -1,17 +1,30 @@ -# theme basic info +# ------------------------------------------------------------ +# Theme basic info (please don't change) +# ------------------------------------------------------------ theme_info: name: ILS version: 2.0.1 author: XPoet repository: https://github.com/XPoet/hexo-theme-ils -# favicon -favicon: images/favicon.png -# avatar -avatar: images/avatar.png +# ------------------------------------------------------------ +# Theme style settings +# ------------------------------------------------------------ +style: + # Theme color + theme_color: "#0066CC" -# navigation menu + # favicon + favicon: images/favicon.png + + # avatar + avatar: images/avatar.png + + +# ------------------------------------------------------------ +# Navigation menu +# ------------------------------------------------------------ menu: Home: / Archives: /archives @@ -21,13 +34,22 @@ menu: # About: /about # ... -# RSS -rss: - enable: true -# comment plugin +# ------------------------------------------------------------ +# RSS +# Dependencies: hexo-generator-feed +# See: https://github.com/hexojs/hexo-generator-feed +# ------------------------------------------------------------ +rss: + enable: false + + +# ------------------------------------------------------------ +# Comment plugin +# ------------------------------------------------------------ comments: - # Valine https://github.com/xCss/Valine + # Valine + # See: https://github.com/xCss/Valine valine: enable: false appid: # your leancloud application appid @@ -35,25 +57,34 @@ comments: meta: # comment input meta, type: Array, values: ['nick','mail','link'] placeholder: # your placeholder - # Gitalk https://github.com/gitalk/gitalk + # Gitalk + # See: https://github.com/gitalk/gitalk gitalk: enable: false github_id: # GitHub repo owner - repository: # Repository name to store issues + repository: # Repository name to store issues client_id: # GitHub Application Client ID client_secret: # GitHub Application Client Secret -# website count + +# ------------------------------------------------------------ +# Website count +# ------------------------------------------------------------ website_count: - # busuanzi http://ibruce.info/2015/04/04/busuanzi/ + # busuanzi + # See: http://ibruce.info/2015/04/04/busuanzi/ busuanzi_count: enable: false site_uv: false site_pv: false page_pv: false + +# ------------------------------------------------------------ # Local Search -# Dependencies: https://github.com/theme-next/hexo-generator-searchdb +# Dependencies: hexo-generator-searchdb +# See: https://github.com/theme-next/hexo-generator-searchdb +# ------------------------------------------------------------ local_search: enable: true @@ -67,36 +98,57 @@ local_search: # Preload the search data when the page loads. preload: false + +# ------------------------------------------------------------ # Post word count -# Dependencies: https://github.com/willin/hexo-wordcount +# Dependencies: hexo-wordcount +# See: https://github.com/willin/hexo-wordcount +# ------------------------------------------------------------ post_wordcount: + enable: false wordcount: false # word count, one article min2read: false # time to read, one article -# Home page article block display settings -home_article: - category: true # show category in article block - tag: true # show tags in article block - tag_limit: 5 # max number of tags shown in article block -# Code Copy +# ------------------------------------------------------------ +# Home page article block display settings +# ------------------------------------------------------------ +home_article: + category: + enable: false # show category in home page article block + limit: 3 # max number of categories shown in home page article block + tag: + enable: false # show tags in home page article block + limit: 5 # max number of tags shown in home page article block + + +# ------------------------------------------------------------ +# Code copy +# ------------------------------------------------------------ code_copy: enable: true - style: flat # values: default | flat | mac + style: flat # values: default | flat | mac -# sidebar tools + +# ------------------------------------------------------------ +# Sidebar tools +# ------------------------------------------------------------ side_tools: - enable: true - position: right # values: left | right + enable: false -# back to top + +# ------------------------------------------------------------ +# Back to top +# ------------------------------------------------------------ back2top: - enable: true - position: right # values: left | right + enable: false + +# ------------------------------------------------------------ # Table of Contents in the Sidebar +# ------------------------------------------------------------ toc: - enable: true + enable: false # Automatically add list number to toc. number: true @@ -104,8 +156,11 @@ toc: # If true, all level of TOC in a post will be displayed, rather than the activated part of it. expand_all: true -# magic theme + +# ------------------------------------------------------------ +# Magic +# ------------------------------------------------------------ magic: enable: true - scale: false - shadow: true + scale: false # scale effect when the mouse hover + shadow: false # shadow effect when the mouse hover diff --git a/layout/_partial/article-meta-info.ejs b/layout/_partial/article-meta-info.ejs index d2d92da..9930427 100644 --- a/layout/_partial/article-meta-info.ejs +++ b/layout/_partial/article-meta-info.ejs @@ -31,12 +31,12 @@ <% } %> - <% if(theme.post_wordcount.wordcount && is_post()){ %> + <% if(is_post() && theme.post_wordcount.enable && theme.post_wordcount.wordcount){ %> <%= wordcount(page.content) %> <%- __('wordcount') %> <% } %> - <% if(theme.post_wordcount.min2read && is_post()){ %> + <% if(is_post() && theme.post_wordcount.enable && theme.post_wordcount.min2read){ %> <%= min2read(page.content) %> <%- __('min2read') %> diff --git a/layout/_partial/footer.ejs b/layout/_partial/footer.ejs index c2c63aa..878cdcc 100644 --- a/layout/_partial/footer.ejs +++ b/layout/_partial/footer.ejs @@ -3,10 +3,6 @@ -
- <%- __('powered_by', 'Hexo') %> | <%- __('theme') %> <%= theme.theme_info.name %> v<%= theme.theme_info.version %> -
<% if (theme.website_count.busuanzi_count.enable) { %>
@@ -22,5 +18,9 @@ <% } %>
<% } %> +
+ <%- __('powered_by', 'Hexo') %> | <%- __('theme') %> <%= theme.theme_info.name %> v<%= theme.theme_info.version %> +
diff --git a/layout/_partial/head.ejs b/layout/_partial/head.ejs index c6d6ef0..d3fcd8e 100644 --- a/layout/_partial/head.ejs +++ b/layout/_partial/head.ejs @@ -21,8 +21,8 @@ <% if (title){ %><%= title %> | <% } %><%= config.title %> - <% if (theme.favicon){ %> - <%- favicon_tag(theme.favicon) %> + <% if (theme.style.favicon){ %> + <%- favicon_tag(theme.style.favicon) %> <% } %> <%- css('css/style') %> <%- export_config() %> diff --git a/layout/_partial/scripts.ejs b/layout/_partial/scripts.ejs index 4816b89..da7c3d3 100644 --- a/layout/_partial/scripts.ejs +++ b/layout/_partial/scripts.ejs @@ -15,9 +15,7 @@ <% } %> <% if (theme.toc.enable) { %> - <%- js(['lib/anime.min.js', 'js/toc.js']) %> + <%- js(['lib/anime.min.js', 'js/toc.js', 'js/post-toc.js']) %> <% } %> - - <%- js('js/post.js') %> <% } %> diff --git a/layout/home-content.ejs b/layout/home-content.ejs index acc30cb..18255ab 100644 --- a/layout/home-content.ejs +++ b/layout/home-content.ejs @@ -24,23 +24,26 @@
<%= date(post.date, 'YYYY-MM-DD') %> <% if (theme.magic.enable === true) { %> - <% if (theme.home_article.category === true) { %> + <% if (theme.home_article.category.enable === true) { %>
    - <% post.categories.forEach((category, i) => { %> -
  • <%= i === 0 ? '' : '> ' %><%= category.name %>
  • + <% post.categories.forEach((category, i) => { + if (theme.home_article.category.limit === 0 || i + 1 <= theme.home_article.category.limit) { %> +
  • + <%= i === 0 ? '' : '> ' %><%= category.name %> +
  • + <% } %> <% }); %>
<% } %> - <% if (theme.home_article.tag === true) { %> + <% if (theme.home_article.tag.enable === true) { %>
    <% post.tags.forEach((tag, i) => { - if (theme.home_article.tag_limit === 0 | i + 1 <= theme.home_article.tag_limit) { %> + if (theme.home_article.tag.limit === 0 || i + 1 <= theme.home_article.tag.limit) { %>
  • <%= i === 0 ? '' : '| ' %><%= tag.name %>
  • diff --git a/layout/page.ejs b/layout/page.ejs index f5ac7f3..7009b42 100644 --- a/layout/page.ejs +++ b/layout/page.ejs @@ -59,8 +59,6 @@ <%- partial('_partial/tools') %>
- -