Support reading_speed language param in single.html

Signed-off-by: D14rn <49399494+D14rn@users.noreply.github.com>
This commit is contained in:
D14rn 2024-11-23 22:17:13 +01:00 committed by GitHub
parent 40c8d5f5ee
commit 857633572e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -43,7 +43,14 @@
3) A page front matter value is set `show_reading_time = true`
*/}}
{{ if (or (eq (.Param "show_reading_time") true) (eq $section.Params.show_reading_time true) )}}
<span class="f6 mv4 dib tracked"> - {{ i18n "readingTime" .ReadingTime }} </span>
{{ $readingTime := .ReadingTime }}
{{ with .Site.Params.reading_speed }}
{{ $readingTime = div (float $.WordCount) . }}
{{ $readingTime = math.Ceil $readingTime }}
{{ end }}
<span class="f6 mv4 dib tracked"> - {{ i18n "readingTime" (int $readingTime) }} </span>
<span class="f6 mv4 dib tracked"> - {{ i18n "wordCount" .WordCount }} </span>
{{ end }}
</header>