layouts/_default/single.html, README.md: add showWordCount option

This commit is contained in:
revsuine 2024-11-25 02:14:56 +00:00
parent ae454bef38
commit 13ca81158d
Signed by: revsuine
GPG key ID: 3F257B68F5BC9339
2 changed files with 15 additions and 1 deletions

View file

@ -7,3 +7,14 @@ the files in my Hugo site's root directory.
This is the theme used on [my website](https://revsuine.xyz/). You can see the website source
[here](https://git.revsuine.xyz/revsuine/revsuine.xyz).
## Configuration
The same as [upstream](https://github.com/panr/hugo-theme-terminal?tab=readme-ov-file#how-to-configure), with the
following changes:
```ini
[params]
# whether to show a page's word count
showWordCount = true
```

View file

@ -16,7 +16,10 @@
<span class="post-author">{{ . }}</span>
{{- end -}}
{{- if and (.Param "readingTime") (eq (.Param "readingTime") true) -}}
<span class="post-reading-time">{{ .ReadingTime }} {{ $.Site.Params.minuteReadingTime | default "min read" }} ({{ .WordCount }} {{ $.Site.Params.words | default "words" }})</span>
<span class="post-reading-time">{{ .ReadingTime }} {{ $.Site.Params.minuteReadingTime | default "min read" }}</span>
{{- end -}}
{{- if and (.Param "showWordCount") (eq (.Param "readingTime") true) -}}
<span class="post-word-count">{{ .WordCount }} {{ $.Site.Params.words | default "words" }}</span>
{{- end -}}
</div>