From ca99e5de86c8c2937747eea3d94d208194ba72e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=AE=87?= <448766534@qq.com> Date: Tue, 7 Jan 2020 14:05:02 +0800 Subject: [PATCH] feat: WordCount --- _config.yml | 8 ++++++ layout/_partial/article.ejs | 11 +++++--- layout/_partial/post/word.ejs | 22 ++++++++++++++++ scripts/default_config.js | 8 ++++++ scripts/filters/index.js | 13 ++++++++++ scripts/filters/meta_generator.js | 17 ++++++++++++ scripts/helpers/ayer-plus-vendors.js | 9 +++++++ scripts/helpers/wordcount.js | 39 ++++++++++++++++++++++++++++ scripts/lib/core.js | 25 ++++++++++++++++++ 9 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 layout/_partial/post/word.ejs create mode 100644 scripts/default_config.js create mode 100644 scripts/filters/index.js create mode 100644 scripts/filters/meta_generator.js create mode 100644 scripts/helpers/ayer-plus-vendors.js create mode 100644 scripts/helpers/wordcount.js create mode 100644 scripts/lib/core.js diff --git a/_config.yml b/_config.yml index df276bc..2737c7a 100644 --- a/_config.yml +++ b/_config.yml @@ -36,6 +36,14 @@ nav_text: # 文章页是否显示目录 toc: true +# https://github.com/willin/hexo-wordcount +# 是否开启字数统计(关闭请设置enable为false) +# 也可以单独在md文件里Front-matter设置`no_word_count: true`属性,来自定义关闭字数统计 +word_count: + enable: true + # 只在文章详情显示(不在首页显示) + only_article_visit: true + # 打赏 # 打赏type设定:0-关闭打赏; 1-文章对应的md文件里有reward:true属性,才有打赏; 2-所有文章均有打赏 reward_type: 2 diff --git a/layout/_partial/article.ejs b/layout/_partial/article.ejs index cb0d557..b565dc4 100644 --- a/layout/_partial/article.ejs +++ b/layout/_partial/article.ejs @@ -12,6 +12,9 @@
<%- partial('post/date', {class_name: 'article-date', date_format: null}) %> <%- partial('post/category') %> + <% if(theme.word_count && theme.word_count.enable && !post.no_word_count){%> + <%- partial('post/word') %> + <% } %>
<% } %> @@ -32,10 +35,10 @@ <% } %> <% if ((theme.reward_type === 2 || (theme.reward_type === 1 && post.reward)) && !index){ %> -
- 打赏 -
- <% } %> +
+ 打赏 +
+ <% } %>