(原创)hexo next主题中使用文章计数计时功能

一定要先安装hexo-wordcount,不然就算配置了next主题,网页中显示的也是空的。
安装方法:
在hexo目录上右键选择”Git Bash Here”,执行

1
npm install hexo-wordcount --save

在next目录下,找到_config.yml,找到post_wordcount,修改如下

1
2
3
4
5
6
7
8
# Post wordcount display settings
# Dependencies: https://github.com/willin/hexo-wordcount
post_wordcount:
item_text: true
wordcount: true
min2read: true
totalcount: true
separated_meta: true

到这边的话,已经初步实现了文章计数计时功能,剩下的就是汉化了,在主题目录下,打开languages\zh-Hans.yml,找打totalcount,修改成总字数或则你任意喜欢的文字,这边是统计博客所有文章字符数的
再打开layout_macro\post.swig,找到{ __(‘post.wordcount’) },修改如下

1
2
3
<span title="{{ __('post.wordcount') }}">
{{ wordcount(post.content) }}字
</span>

找到{ __(‘post.min2read’) },修改如下

1
2
3
<span title="{{ __('post.min2read') }}">
{{ min2read(post.content) }}分钟
</span>

大功告成!!!

多谢打赏
-------------本文结束感谢您的阅读-------------
0%