Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add wordcount support #384

Merged
merged 3 commits into from
May 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ show_category_count: false ## If you want to show the count of categories in the
toc_number: true ## If you want to add list number to toc please set the value to true.
shareto: false ## If you want to use the share button please set the value to true, you must have hexo-helper-qrcode installed.
busuanzi: false ## If you want to use Busuanzi page views please set the value to true.
wordcount: false ## If you want to use wordcount views please set the value to true, and make sure hexo-wordcount is installed
widgets_on_small_screens: false ## Set to true to enable widgets on small screens.
canvas_nest:
enable: false ## If you want to use dynamic background please set the value to true, you can also fill the following parameters to customize the dynamic effect, or just leave them blank to keep the default effect.
Expand All @@ -86,7 +87,7 @@ post_copyright:
enable: false ## If you want to display the copyright info after each post, please set the value to true and fill the following items on your need.
author: ## Your author name, e.g. tufu9441
copyright_text: ## Your copyright text, e.g. The author owns the copyright, please indicate the source reproduced.

menu:
- page: home
directory: .
Expand Down Expand Up @@ -153,6 +154,7 @@ version: 0.0.0
- toc_number - Show the list number of toc
- shareto - Enable share button, with the dependency on the plugin [hexo-helper-qrcode](https://github.com/yscoder/hexo-helper-qrcode)
- busuanzi - Enable [Busuanzi](http://busuanzi.ibruce.info) page views
- wordcount - Enable [hexo-wordcount](https://www.npmjs.com/package/hexo-wordcount) page views
- widgets_on_small_screens - Show the widgets at the bottom of small screens
- [canvas_nest](https://github.com/hustcc/canvas-nest.js) - Enable dynamic background
- donate - Enable donate button after each post
Expand Down
3 changes: 2 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ show_category_count: false ## If you want to show the count of categories in the
toc_number: true ## If you want to add list number to toc please set the value to true.
shareto: false ## If you want to use the share button please set the value to true, you must have hexo-helper-qrcode installed.
busuanzi: false ## If you want to use Busuanzi page views please set the value to true.
wordcount: false ## If you want to use wordcount views please set the value to true, and make sure that hexo-wordcount is installed
widgets_on_small_screens: false ## Set to true to enable widgets on small screens.
canvas_nest:
enable: false ## If you want to use dynamic background please set the value to true, you can also fill the following parameters to customize the dynamic effect, or just leave them blank to keep the default effect.
Expand All @@ -58,7 +59,7 @@ post_copyright:
enable: false ## If you want to display the copyright info after each post, please set the value to true and fill the following items on your need.
author: ## Your author name, e.g. tufu9441
copyright_text: ## Your copyright text, e.g. The author owns the copyright, please indicate the source reproduced.

menu:
- page: home
directory: .
Expand Down
2 changes: 2 additions & 0 deletions languages/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ copyright_author_prefix: "Author: "
copyright_link_prefix: "Blog Link: "
copyright_declare_prefix: "Copyright Declaration: "
copyright_default_text: "The author owns the copyright. Please indicate the source reproduced!"
word_cnt: Words
read_time: Minutes
2 changes: 2 additions & 0 deletions languages/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ copyright_author_prefix: 本文作者:
copyright_link_prefix: 本文链接:
copyright_declare_prefix: 版权声明:
copyright_default_text: 本博客所有文章除特别声明外,均采用 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/cn/" rel="external nofollow" target="_blank">CC BY-NC-SA 3.0 CN</a> 许可协议。转载请注明出处!
word_cnt:
read_time: 分钟
11 changes: 11 additions & 0 deletions layout/_partial/wordcount.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
span.post-time
span.post-meta-item-text= ' | '
span.post-meta-item-icon
i(class="fa fa-keyboard-o")
span.post-count= ' '+wordcount(page.content)
span.post-meta-item-text= " "+__('word_cnt')
span.post-time= ' | '
span.post-meta-item-icon
i(class="fa fa-hourglass-half")
span.post-count= ' '+min2read(page.content)
span.post-meta-item-text= ' '+__('read_time')
2 changes: 2 additions & 0 deletions layout/post.pug
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ block content
span#busuanzi_container_page_pv= ' | '
span#busuanzi_value_page_pv
span= ' ' + __('Hits')
if theme.wordcount == true
include _partial/wordcount.pug
if theme.disqus
a.disqus-comment-count(data-disqus-identifier=page.path, href=url_for(page.path) + '#disqus_thread')
if theme.changyan
Expand Down