next添加字数和阅读时长


  • 把theme底下的_config.yml里对应的设置开启
1
2
3
4
5
6
post_wordcount:
item_text: true
wordcount: true # 单篇 字数统计
min2read: true # 单篇 阅读时长
totalcount: false # 网站 字数统计
separated_meta: true
  • 安装hexo-wordcount插件
1
npm i --save hexo-wordcount

Node 版本 7.6.0 之前,请安装 2.x 版本 (Node.js v7.6.0 and previous) ,安装命令如下:*

1
npm install hexo-wordcount@2 --save
  • 这样设置后对应的只有数字,没有“字”和“分钟”。打开themes/next/layout/_macro/post.swig,再通过以下设置即可:

    添加“

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

改为

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

添加“分钟

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

改为

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

引用


提出正确的问题,往往等于解决了问题的一大半!

多少都是爱
0%