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

feat: add busuanzi views count #793

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions assets/data/cdn/cdnjs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ libFiles:
# cookieconsent@3.1.1 https://github.com/osano/cookieconsent
cookieconsentCSS: cookieconsent/3.1.1/cookieconsent.min.css
cookieconsentJS: cookieconsent/3.1.1/cookieconsent.min.js
# busuanzi@2.3 http://ibruce.info/2015/04/04/busuanzi
busuanziJS: busuanzi/2.3.0/bsz.pure.mini.js
2 changes: 2 additions & 0 deletions assets/data/cdn/jsdelivr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ libFiles:
# cookieconsent@3.1.1 https://github.com/osano/cookieconsent
cookieconsentCSS: cookieconsent@3.1.1/build/cookieconsent.min.css
cookieconsentJS: cookieconsent@3.1.1/build/cookieconsent.min.js
# busuanzi@2.3 http://ibruce.info/2015/04/04/busuanzi
busuanziJS: busuanzi@2.3.0/bsz.pure.mini.min.js
4 changes: 3 additions & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@
# whether to show the full text content in RSS
# 是否在 RSS 中显示全文内容
rssFullText = false
# whether to show page views count
# 是否开启阅读量计数
viewsCount = true
# Table of the contents config
# 目录配置
[params.page.toc]
Expand Down Expand Up @@ -429,7 +432,6 @@
# automatically adapt the current theme i18n configuration when empty
# 为空时自动适配当前主题 i18n 配置
lang = ""
visitor = true
recordIP = true
highlight = true
enableQQ = false
Expand Down
3 changes: 3 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ ignoreErrors = ["error-remote-getjson", "error-missing-instagram-accesstoken"]
# whether to show the full text content in RSS
# 是否在 RSS 中显示全文内容
rssFullText = false
# whether to show page views count
# 是否开启阅读量计数
viewsCount = true
# Table of the contents config
# 目录配置
[params.page.toc]
Expand Down
6 changes: 6 additions & 0 deletions layouts/partials/assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@
{{- $config = $cookieconsentConfig | dict "cookieconsent" | merge $config -}}
{{- end -}}

{{- /* busuanzi */ -}}
{{- if .Site.Params.page.viewsCount -}}
{{- $source := $cdn.busuanziJS | default "lib/busuanzi/bsz.pure.mini.js" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
{{- end -}}

{{- range $params.library.css -}}
{{- dict "Source" . "Fingerprint" $fingerprint | dict "Scratch" $.Scratch "Data" | partial "scratch/style.html" -}}
{{- end -}}
Expand Down
6 changes: 3 additions & 3 deletions layouts/posts/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ <h2 class="single-subtitle">{{ . }}</h2>
<i class="fas fa-pencil-alt fa-fw" aria-hidden="true"></i>&nbsp;{{ T "wordCount" .WordCount }}&nbsp;
<i class="far fa-clock fa-fw" aria-hidden="true"></i>&nbsp;{{ T "readingTime" .ReadingTime }}&nbsp;
{{- $comment := .Scratch.Get "comment" | default dict -}}
{{- if $comment.enable | and $comment.valine.enable | and $comment.valine.visitor -}}
<span id="{{ .RelPermalink }}" class="leancloud_visitors" data-flag-title="{{ .Title }}">
<i class="far fa-eye fa-fw" aria-hidden="true"></i>&nbsp;<span class=leancloud-visitors-count></span>&nbsp;{{ T "views" }}
{{- if .Site.Params.page.viewsCount -}}
<span id="busuanzi_container_page_pv">
<i class="far fa-eye fa-fw" aria-hidden="true"></i>&nbsp;<span id="busuanzi_value_page_pv"></span>&nbsp;{{ T "views" }}
</span>&nbsp;
{{- end -}}
</div>
Expand Down