Feat: add total word count feature in section and remove from footer (#124)

This commit is contained in:
Cell
2022-05-20 11:30:19 +08:00
parent a7c305583a
commit e82a6549a6
17 changed files with 90 additions and 73 deletions
+1
View File
@@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
> Add hugo new features support.
> Snapshot:
- :sparkles: Feat: add total word count feature in section and remove from footer ([#124](https://github.com/Lruihao/FixIt/issues/124))
- :sparkles: Feat: enhance auto toc feature ([#104](https://github.com/Lruihao/FixIt/issues/104) [#136](https://github.com/Lruihao/FixIt/issues/136))
- :sparkles: Feat(SEO): add options to make output baidu_urls.txt file ([#138](https://github.com/Lruihao/FixIt/issues/138))
- :bug: Fix: Giscus comments invalid config `inputPosition`
+15
View File
@@ -1,9 +1,24 @@
.archive {
.single-title {
padding: 1rem 0 0.5rem;
margin: 0;
font-size: 1.6rem;
font-weight: bold;
line-height: 140%;
text-align: right;
}
.single-subtitle {
margin: 0.4rem 0;
font-size: 1.2rem;
font-weight: normal;
font-style: italic;
line-height: 100%;
text-align: right;
}
.group-title {
font-size: 1.2rem;
margin-top: 1.5rem;
margin-bottom: 1rem;
}
+4 -4
View File
@@ -33,6 +33,10 @@ other = "Artikel"
[allSome]
other = "Alle {{ .Some }}"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[tag]
other = "Tag"
@@ -152,10 +156,6 @@ other = "enthalten in {{ .Categories }}"
one = "Ein wort"
other = "{{ .Count }} wörter"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[readingTime]
one = "Eine minute"
other = "{{ .Count }} minuten"
+4 -4
View File
@@ -32,6 +32,10 @@ other = "Posts"
[allSome]
other = "All {{ .Some }}"
[totalwordCount]
one = "Total one word"
other = "Total {{ .Count }} words"
[tag]
other = "Tag"
@@ -148,10 +152,6 @@ other = "included in {{ .Categories }}"
one = "One word"
other = "{{ .Count }} words"
[totalwordCount]
one = "Total one word"
other = "Total {{ .Count }} words"
[readingTime]
one = "One minute"
other = "{{ .Count }} minutes"
+4 -4
View File
@@ -33,6 +33,10 @@ other = "Artículos"
[allSome]
other = "Todo {{ .Some }}"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[tag]
other = "Etiqueta"
@@ -152,10 +156,6 @@ other = "incluido en {{ .Categories }}"
one = "Una palabra"
other = "{{ .Count }} palabras"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[readingTime]
one = "Un minuto"
other = "{{ .Count }} minutos"
+4 -4
View File
@@ -33,6 +33,10 @@ other = "Posts"
[allSome]
other = "Tous {{ .Some }}"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[tag]
other = "Balise"
@@ -152,10 +156,6 @@ other = "inclus dans {{ .Categories }}"
one = "Un mot"
other = "{{ .Count }} mots"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[readingTime]
one = "Une minute"
other = "{{ .Count }} minutes"
+4 -4
View File
@@ -33,6 +33,10 @@ other = "Articoli"
[allSome]
other = "Tutti {{ .Some }}"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[tag]
other = "Etichetta"
@@ -152,10 +156,6 @@ other = "incluso in {{ .Categories }}"
one = "Una parola"
other = "{{ .Count }} parole"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[readingTime]
one = "Un minuto"
other = "{{ .Count }} minuti"
+4 -4
View File
@@ -33,6 +33,10 @@ other = "Posty"
[allSome]
other = "Wszystkie {{ .Some }}"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[tag]
other = "Tag"
@@ -149,10 +153,6 @@ other = "zawarty w {{ .Categories }}"
one = "Jedno słowo"
other = "{{ .Count }} słów"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[readingTime]
one = "Jedna minuta"
other = "{{ .Count }} minuty"
+4 -4
View File
@@ -33,6 +33,10 @@ other = "Posts"
[allSome]
other = "Todos {{ .Some }}"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[tag]
other = "Tag"
@@ -152,10 +156,6 @@ other = "incluido em {{ .Categories }}"
one = "Uma palavra"
other = "{{ .Count }} palavras"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[readingTime]
one = "Um minuto"
other = "{{ .Count }} minutos"
+4 -4
View File
@@ -33,6 +33,10 @@ other = "Articole"
[allSome]
other = "Toate {{ .Some }}"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[tag]
other = "Etichetă"
@@ -152,10 +156,6 @@ other = "inclus în {{ .Categories }}"
one = "Un cuvânt"
other = "{{ .Count }} cuvinte"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[readingTime]
one = "Un minut"
other = "{{ .Count }} minute"
+4 -4
View File
@@ -33,6 +33,10 @@ other = "Статьи"
[allSome]
other = "Все {{ .Some }}"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[tag]
other = "Тэг"
@@ -152,10 +156,6 @@ other = "включен в {{ .Categories }}"
one = "Одно слово"
other = "{{ .Count }} слов"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[readingTime]
one = "Одна минута"
other = "{{ .Count }} минут"
+4 -4
View File
@@ -33,6 +33,10 @@ other = "Постови"
[allSome]
other = "Све {{ .Some }}"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[tag]
other = "Таг"
@@ -149,10 +153,6 @@ other = "укључено {{ .Categories }}"
one = "Једна реч"
other = "{{ .Count }} речи"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[readingTime]
one = "Један минут"
other = "{{ .Count }} минута"
+4 -4
View File
@@ -32,6 +32,10 @@ other = "Bài viết"
[allSome]
other = "Tất cả {{ .Some }}"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[tag]
other = "Nhãn"
@@ -151,10 +155,6 @@ other = "trong {{ .Categories }}"
one = "One word"
other = "{{ .Count }} từ"
[totalwordCount]
one = "" # waitting for translation
other = "" # waitting for translation
[readingTime]
one = "One minute"
other = "{{ .Count }} phút"
+3 -3
View File
@@ -33,6 +33,9 @@ other = "文章"
[allSome]
other = "所有{{ .Some }}"
[totalwordCount]
other = "总计约 {{ .Count }} 字"
[tag]
other = "标签"
@@ -154,9 +157,6 @@ other = "收录于 {{ .Categories }}"
[wordCount]
other = "约 {{ .Count }} 字"
[totalwordCount]
other = "总计约 {{ .Count }} 字"
[readingTime]
other = "预计阅读 {{ .Count }} 分钟"
+3 -3
View File
@@ -33,6 +33,9 @@ other = "文章"
[allSome]
other = "所有{{ .Some }}"
[totalwordCount]
other = "總計約 {{ .Count }} 字"
[tag]
other = "標籤"
@@ -154,9 +157,6 @@ other = "收錄於 {{ .Categories }}"
[wordCount]
other = "約 {{ .Count }} 字"
[totalwordCount]
other = "總計約 {{ .Count }} 字"
[readingTime]
other = "預計閱讀 {{ .Count }} 分鐘"
+24 -6
View File
@@ -4,11 +4,29 @@
{{- define "content" -}}
<div class="page archive">
{{- /* Title */ -}}
<h2 class="single-title animate__animated animate__pulse animate__faster">
{{- .Params.Title | default (T .Section) | default .Section | dict "Some" | T "allSome" }}
<sup>{{- len .Pages -}}</sup>
</h2>
<div class="header">
{{- /* Title */ -}}
<h1 class="single-title animate__animated animate__pulse animate__faster">
{{- .Params.Title | default (T .Section) | default .Section | dict "Some" | T "allSome" }}
<sup>{{- len .Pages -}}</sup>
</h1>
{{- /* Total word count */ -}}
{{- /* See https://github.com/Lruihao/FixIt/issues/124 */ -}}
{{- $localData := newScratch -}}
{{- range .Pages -}}
{{- $localData.Add "totalWordCount" .WordCount -}}
{{- end -}}
{{- with ($localData.Get "totalWordCount") -}}
{{- $humanizedNum := . -}}
{{- if ge $humanizedNum 1000 -}}
{{- $humanizedNum = printf "%.2fK" (div $humanizedNum 1000.0) -}}
{{- end -}}
<p class="single-subtitle total-word-count" title='{{- T "totalwordCount" . }}'>
<i class="fa-regular fa-keyboard fa-fw"></i>
{{ T "totalwordCount" (dict "Count" $humanizedNum) -}}
</p>
{{- end -}}
</div>
{{- /* Paginate */ -}}
{{- if .Pages -}}
@@ -20,7 +38,7 @@
{{- end -}}
{{- partial "recently-updated.html" . -}}
{{- range $pages.PageGroups -}}
<h3 class="group-title">{{ .Key }}</h3>
<h2 class="group-title">{{ .Key }}</h2>
{{- range .Pages -}}
<article class="archive-item">
<a href="{{ .RelPermalink }}" class="archive-item-link">
-17
View File
@@ -50,23 +50,6 @@
{{- if .Site.Params.footer.siteTime -}}
<span class="site-time" title='{{ T "siteRunning" }}'><i class="fa-solid fa-heartbeat fa-fw animate-icon"></i>&nbsp;<span class="run-times">{{- T "siteRunning" -}}</span></span>
{{- end -}}
{{- /* Total word count */ -}}
{{- /* There is a fatal bug. See https://github.com/Lruihao/FixIt/issues/124 */ -}}
{{- /* if ne .Site.Params.footer.wordCount false */ -}}
{{- if false -}}
{{- $localData := newScratch -}}
{{- range (where .Site.Pages "Kind" "page") -}}
{{- $localData.Add "totalWordCount" .WordCount -}}
{{- end -}}
{{- with ($localData.Get "totalWordCount") -}}
{{- $humanizedNum := . -}}
{{- if ge $humanizedNum 1000 -}}
{{- $humanizedNum = printf "%.2fK" (div $humanizedNum 1000.0) -}}
{{- end -}}
<span class="total-word-count footer-divider" title='{{- T "totalwordCount" . }}'><i class="fa-regular fa-keyboard fa-fw"></i>&nbsp;{{- T "totalwordCount" (dict "Count" $humanizedNum) -}}</span>
{{- end -}}
{{- end -}}
</div>
{{- end -}}