diff --git a/README.md b/README.md index e49ab69b..75932cd3 100644 --- a/README.md +++ b/README.md @@ -232,6 +232,7 @@ pagination.pagerSize = 5 title = "Terminal" [languages.en.params] + # readingSpeed = 212 # in words per minute, default is 212 subtitle = "A simple, retro theme for Hugo" owner = "" keywords = "" @@ -243,8 +244,11 @@ pagination.pagerSize = 5 olderPosts = "Older posts" missingContentMessage = "Page not found..." missingBackButtonLabel = "Back to home page" - minuteReadingTime = "min read" words = "words" + word = "word" + minute = "minute" + minutes = "minutes" + to_read = "to read" [languages.en.params.logo] logoText = "Terminal" diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 2ee08543..41441789 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -15,8 +15,9 @@

{{- with .Params.Author -}} {{ . }} {{- end -}} - {{- if and (.Param "readingTime") (eq (.Param "readingTime") true) -}} - {{ .ReadingTime }} {{ $.Site.Params.minuteReadingTime | default "min read" }} ({{ .WordCount }} {{ $.Site.Params.words | default "words" }}) + {{- if and (.Param "readingTime") (eq (.Param "readingTime") true) -}}{{ $customReadingTime := div (float .WordCount) (.Site.Params.readingSpeed | default 212) }}{{ $customReadingTime = math.Ceil $customReadingTime }}{{ $customReadingTime }} {{ if eq $customReadingTime 1.0 }}{{ $.Site.Params.minute | default "minute" }}{{ else }}{{ $.Site.Params.minutes | default "minutes" }}{{ end }} {{ $.Site.Params.to_read | default "to read" }} ({{ .WordCount }} {{ if eq .WordCount 1 }}{{ $.Site.Params.word | default "word" }}{{ else }}{{ $.Site.Params.words | default "words" }}{{ end }}) {{- end -}}