Hexo博客NexT主题下添加字数统计和阅读时长

安装hexo-symbols-count-time

1
$ npm install hexo-symbols-count-time --save

Click and drag to move

如果安装完报如下提醒,还需安装eslint

1
2
D:\hexo\blog>npm install hexo-symbols-count-time --save
npm WARN babel-eslint@10.0.1 requires a peer of eslint@>= 4.12.1 but none is installed. You must install peer dependencies yourself.

Click and drag to move

安装eslint

1
$ npm install eslint --save

Click and drag to move

在站点配置文件添加如下配置

1
2
3
4
5
6
symbols_count_time:
symbols: true # 文章字数统计
time: true # 文章阅读时长
total_symbols: true # 站点总字数统计
total_time: true # 站点总阅读时长
exclude_codeblock: false # 排除代码字数统计

Click and drag to move

在NexT主题配置文件添加如下配置(NexT主题已支持该插件,有的话无需再添加)

1
2
3
4
5
6
7
8
9
# Post wordcount display settings
# Dependencies: https://github.com/theme-next/hexo-symbols-count-time
symbols_count_time:
separated_meta: true # 是否另起一行(true的话不和发表时间等同一行)
item_text_post: true # 首页文章统计数量前是否显示文字描述(本文字数、阅读时长)
item_text_total: false # 页面底部统计数量前是否显示文字描述(站点总字数、站点阅读时长)
awl: 4 # Average Word Length
wpm: 275 # Words Per Minute(每分钟阅读词数)
suffix: mins.

Click and drag to move

效果如下:

站点统计

imgClick and drag to move

文章统计

imgClick and drag to move

参考

theme-next/hexo-symbols-count-time