D0n9X1n / hexo-blog-encrypt

Yet, just another hexo plugin for security.
https://www.npmjs.com/package/hexo-blog-encrypt
MIT License
971 stars 101 forks source link

文章字数统计已通过issue解决,站点字数统计是否有办法解决? #151

Closed ukityh closed 3 years ago

ukityh commented 3 years ago

字数统计错误

通过给文章添加了判断句,可以统计出正确字数,然而站点总字数的统计依旧统计的是文档加密后的字数。

使用的插件是hexo-wordcount,站点总字数的统计语句是<%= totalcount(site) %>,尝试添加了site.origin无效

请问有办法解决吗?

D0n9X1n commented 3 years ago

这个你需要改 hexo-wordcount 插件代码了。 定位到:https://github.com/willin/hexo-wordcount/blob/ccceed3df38cc1529ba7bd067d72f8a440ae94a2/index.js#L29

hexo.extend.helper.register('totalcount', function (site) {
  var count = 0;
  site.posts.forEach(function (post) {
    // 判断下 post.origin 是否有值,有的话用 origin 来计算
    var len = post.origin ? counter(post.origin) : counter(post.content);
    count += len[0] + len[1];
  });
  if (count < 1000) {
    return count;
  }
  return Math.round(count / 100) / 10 + 'k';
});

没有测试,大概意思就是这样,你可以尝试下。

ukityh commented 3 years ago

噢噢噢!!是可以的!!非常感谢!!