diff --git a/scripts/helpers/wordcount.js b/scripts/helpers/wordcount.js index ce840f70..1d8acea6 100644 --- a/scripts/helpers/wordcount.js +++ b/scripts/helpers/wordcount.js @@ -5,6 +5,9 @@ const { stripHTML } = require('hexo-util'); const getWordCount = (post) => { + if (!post.wordcount) { + post.wordcount = stripHTML(post.content).replace(/\r?\n|\r/g, '').replace(/\s+/g, '').length; + } return post.wordcount; }; @@ -32,10 +35,3 @@ hexo.extend.helper.register('wordtotal', (site) => { }); return symbolsCount(count); }); - -hexo.extend.filter.register('after_post_render', (page) => { - const meta = hexo.theme.config.post.meta; - if (meta.wordcount.enable || meta.min2read.enable) { - page.wordcount = stripHTML(page.content).replace(/\r?\n|\r/g, '').replace(/\s+/g, '').length; - } -}, 0);