From 438c484d77b64bcb7650145df087c28575f6fd56 Mon Sep 17 00:00:00 2001 From: FoxerLee Date: Wed, 12 Aug 2020 22:14:33 -0400 Subject: [PATCH] add wordcount, time to read --- README.md | 12 ++++++++++-- _config.yml | 6 ++++++ languages/en.yml | 4 +++- languages/zh-CN.yml | 4 +++- layout/_partial/article-meta-info.ejs | 10 ++++++++++ 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b06bc9c..2d9cfb3 100644 --- a/README.md +++ b/README.md @@ -67,12 +67,12 @@ - [x] 页面滚动百分比提示。 - [x] 一键快速回到顶部。 - [x] 无 jQuery,代码精简。 +- [x] 文章字数统计 +- [x] 文章阅读时长 ### Unfinished 未完成 - [ ] 文章版权信息 -- [ ] 文章字数统计 -- [ ] 文章阅读时长 - [ ] 文章支持显示公式 - [ ] 在线更改字体和字号 - [ ] 打赏功能 @@ -237,6 +237,14 @@ magic: enable: false # 是否显示侧边栏 fixed: true # 侧边栏是否固定 position: right # 侧边栏位置 values: left | right + +# 文章字数统计、阅读时长 +# 需要安装 https://github.com/willin/hexo-wordcount +# npm i --save hexo-wordcount +post_wordcount: + wordcount: true # 字数统计 + min2read: true # 阅读时长 + ``` ### Comment 评论 diff --git a/_config.yml b/_config.yml index 8dd1222..c1767a5 100644 --- a/_config.yml +++ b/_config.yml @@ -99,3 +99,9 @@ magic: enable: false fixed: true position: right # values: left | right + +# Post wordcount display settings +# Dependencies: https://github.com/willin/hexo-wordcount +post_wordcount: + wordcount: true # word count, one article + min2read: true # time to read, one article \ No newline at end of file diff --git a/languages/en.yml b/languages/en.yml index 920784f..f0021b5 100644 --- a/languages/en.yml +++ b/languages/en.yml @@ -22,4 +22,6 @@ site_uv: UV site_pv: PV links: Links top: TOP -read_more: Read more \ No newline at end of file +read_more: Read more +wordcount: Words +min2read: Mins \ No newline at end of file diff --git a/languages/zh-CN.yml b/languages/zh-CN.yml index cfd392c..0de259c 100644 --- a/languages/zh-CN.yml +++ b/languages/zh-CN.yml @@ -22,4 +22,6 @@ site_uv: 访问人数 site_pv: 总访问量 links: 友链 top: 顶置 -read_more: 阅读全文 \ No newline at end of file +read_more: 阅读全文 +wordcount: 字 +min2read: 分钟 \ No newline at end of file diff --git a/layout/_partial/article-meta-info.ejs b/layout/_partial/article-meta-info.ejs index 512a914..81a1899 100644 --- a/layout/_partial/article-meta-info.ejs +++ b/layout/_partial/article-meta-info.ejs @@ -31,4 +31,14 @@ <% } %> + <% if(theme.post_wordcount.wordcount){ %> + + <%= wordcount(page.content) %> <%- __('wordcount') %> + + <% } %> + <% if(theme.post_wordcount.min2read){ %> + + <%= min2read(page.content) %> <%- __('min2read') %> + + <% } %> \ No newline at end of file