一定要先安裝hexo-wordcount,不然就算配置了next主題,網頁中顯示的也是空的。
安裝方法:
在hexo目錄上右鍵選擇"Git Bash Here",執行
npm install hexo-wordcount --save
在next目錄下,找到_config.yml,找到post_wordcount,修改如下
# 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’) },修改如下
<span title="{{ __('post.wordcount') }}">
{{ wordcount(post.content) }}字
</span>
找到{ __(‘post.min2read’) },修改如下
<span title="{{ __('post.min2read') }}">
{{ min2read(post.content) }}分鐘
</span>
大功告成!!!