hexo笔记六:next主题添加字数统计和阅读时长估计

先看效果图:
在这里插入图片描述
在正文标题下会出现字数统计和阅读时长,如上图。
在这里插入图片描述
同时,在网页的最下侧会出现全站的字数统计值,如上图。

这篇博客记录下怎么实现。

1 安装相关的插件:

npm i --save hexo-wordcount

2 更改主题配置文件:

cd 博客目录
vim themes/next/_config.yml

# 这些都是配置文件里都有的,将其值都设置为true,
# 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

3 修改主题相关界面文件:

cd 博客目录
vim themes/next/layout/_macro/post.swig

更改两处值,找到该值,在后面添加中文单位即可:

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

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

4 重新生成博客即可:

cd 博客目录
hexo g

猜你喜欢

转载自blog.csdn.net/Awt_FuDongLai/article/details/107425490