Skip to content

Commit

Permalink
✨ Feat: add total word count support in footer (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Apr 28, 2022
1 parent 66847cf commit 96a4916
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file.
- :sparkles: Feat: link shortcode add `external-icon` option ([#96](https://github.com/Lruihao/FixIt/issues/96))
- :sparkles: Feat: add GitHub Corners support ([#106](https://github.com/Lruihao/FixIt/issues/106))
- :sparkles: Feat: add local avatar and gravatar support for post author ([#125](https://github.com/Lruihao/FixIt/issues/125))
- :sparkles: Feat: add total word count support in footer ([#124](https://github.com/Lruihao/FixIt/issues/124))
- :sparkles: Feat: add "Edit this page" button support ([#103](https://github.com/Lruihao/FixIt/issues/103))
- :sparkles: Feat: add count badge for taxonomy ([#122](https://github.com/Lruihao/FixIt/issues/122))
- :zap: Perf: add Gravatar config support
Expand Down
5 changes: 4 additions & 1 deletion exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -593,12 +593,15 @@ enableEmoji = true
# whether to show the author
# 是否显示作者
author = true
# site creation time
# site creation year
# 网站创立年份
since = 2021
# Site creation time since v0.2.14
# 网站创立时间 since v0.2.14
siteTime = '2021-12-18T16:15:22+08:00'
# whether to show total word count of site content since v0.2.14
# 是否显示网站内容总字数 since v0.2.14
wordCount = true
# Public network security only in China (HTML format is supported) since v0.2.12
# 公网安备信息,仅在中国使用 (支持 HTML 格式) since v0.2.12
gov = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,12 @@ Please open the code block below to view the complete sample configuration :(far
copyright = true
# {{< version 0.2.0 >}} whether to show the author
author = true
# Site creation time
# Site creation year
since = 2019
# {{< version 0.2.14 >}} Site creation time
siteTime = '' # e.g. '2019-02-03T19:30:34+08:00'
# {{< version 0.2.14 >}} whether to show total word count of site content
wordCount = true
# ICP info only in China (HTML format is supported)
icp = ""
# license info (HTML format is supported)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ hugo
since = 2019
# {{< version 0.2.14 >}} 网站创立时间
siteTime = '' # 例:'2019-02-03T19:30:34+08:00'
# {{< version 0.2.14 >}} 是否显示网站内容总字数
wordCount = true
# {{< version 0.2.12 >}} 公网安备信息,仅在中国使用(支持 HTML 格式)
gov = ""
# {{< version 0.2.12 changed >}} ICP 备案信息,仅在中国使用(支持 HTML 格式)
Expand Down
41 changes: 24 additions & 17 deletions layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,36 @@

{{- /* License */ -}}
{{- with .Site.Params.footer.license -}}
{{- if $.Site.Params.footer.copyright | or $.Site.Params.footer.author -}}
<span class="footer-divider"></span>
{{- end -}}
<span class="license">{{ . | safeHTML }}</span>
<span class="license footer-divider">{{ . | safeHTML }}</span>
{{- end -}}
</div>
{{- end -}}

<div class="footer-line statistics">
{{- /* TODO: The parameter `ibruce.siteTime` will be deleted in v0.2.15 */ -}}
{{- if .Site.Params.ibruce.siteTime | or .Site.Params.footer.siteTime -}}
<span class="site-time" title={{ T "siteRunning" }}><i class="fas fa-heartbeat fa-fw animate-icon"></i>&nbsp;<span class="run-times">Loading ...</span></span>
{{- end -}}
</div>
{{- /* TODO: The parameter `ibruce.siteTime` will be deleted in v0.2.15 */ -}}
{{- if .Site.Params.ibruce.siteTime | or .Site.Params.footer.siteTime | or .Site.Params.footer.wordCount -}}
<div class="footer-line statistics">
{{- if .Site.Params.ibruce.siteTime | or .Site.Params.footer.siteTime -}}
<span class="site-time" title='{{ T "siteRunning" }}'><i class="fas fa-heartbeat fa-fw animate-icon"></i>&nbsp;<span class="run-times">Loading ...</span></span>
{{- end -}}

{{- /* Total word count */ -}}
{{- if ne .Site.Params.footer.wordCount false -}}
{{- $localData := newScratch -}}
{{- range (where .Site.Pages "Kind" "page") -}}
{{- $localData.Add "totalWordCount" .WordCount -}}
{{- end -}}
{{- /* TODO i18n */ -}}
<span class="total-word-count footer-divider">{{- $localData.Get "totalWordCount" -}}</span>
{{- end -}}
</div>
{{- end -}}

{{- /* 不蒜子 */ -}}
{{- if eq .Site.Params.ibruce.enable true -}}
<div class="footer-line ibruce">
<span id="busuanzi_container_site_uv" title={{ T "siteUV" }}><i class="far fa-user fa-fw"></i><span id="busuanzi_value_site_uv"><i class="fa fa-spinner fa-spin fa-fw"></i></span></span>
<span id="busuanzi_container_site_pv" class="footer-divider" title={{ T "sitePV" }}><i class="far fa-eye fa-fw"></i>&nbsp;<span id="busuanzi_value_site_pv"><i class="fa fa-spinner fa-spin fa-fw"></i></span></span>
<span id="busuanzi_container_site_uv" title='{{ T "siteUV" }}'><i class="far fa-user fa-fw"></i>&nbsp;<span id="busuanzi_value_site_uv"><i class="fa fa-spinner fa-spin fa-fw"></i></span></span>
{{- /* remove spaces */ -}}
<span id="busuanzi_container_site_pv" class="footer-divider" title='{{ T "sitePV" }}'><i class="far fa-eye fa-fw"></i>&nbsp;<span id="busuanzi_value_site_pv"><i class="fa fa-spinner fa-spin fa-fw"></i></span></span>
</div>
{{- end -}}

Expand All @@ -69,13 +79,10 @@
{{- with .Site.Params.footer.gov -}}
<span class="gov">{{ . | safeHTML }}</span>
{{- end -}}

{{- /* ICP */ -}}
{{- with .Site.Params.footer.icp -}}
{{- if $.Site.Params.footer.gov -}}
<span class="footer-divider"></span>
{{- end -}}
<span class="icp">{{ . | safeHTML }}</span>
<span class="icp footer-divider">{{ . | safeHTML }}</span>
{{- end -}}
</div>
{{- end -}}
Expand Down

0 comments on commit 96a4916

Please sign in to comment.