1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-12-27 10:52:09 +00:00
seirdy.one/layouts/partials/post-meta/wordcount.html

25 lines
1.1 KiB
HTML
Raw Normal View History

{{ $displayCount := string .WordCount -}}
{{- if gt .WordCount 5000 -}}
{{- $thousands := string (div .WordCount 1000) -}}
{{- $displayCount = printf "%s thousand" $thousands -}}
About
2022-06-02 04:49:04 +00:00
{{- end -}}
<data itemprop="wordCount" value="{{ .WordCount }}">
2022-06-02 04:49:04 +00:00
{{- $displayCount -}}
</data> words
{{- with .ReadingTime -}}
{{- $displayTime := string . -}}
{{- if gt . 60 -}}
{{- $hours := div . 60 -}}
{{- $minutes := mod . 60 -}}
{{- $displayTime = (printf "%d&#160;hour and %d" $hours $minutes) | safeHTML -}}
{{- end -}}
{{- $indefiniteArticle := "a" -}}
{{- $vowelNumbers := slice 11 18 -}} {{/* 11 and 18 aren't qualified by "short" or "somewhat long" and start with vowel sounds so we need to say "an" instead of "a" */}}
{{- if (in $vowelNumbers .) -}}
{{- $indefiniteArticle = "an" -}}
{{- end -}}
; {{ $indefiniteArticle }} {{ if lt . 10 }}short {{ else if and (gt . 20) (lt . 30) }}somewhat long {{ else if and (gt . 29) (lt . 60) }}long {{ else if gt . 59 }} very long {{ end -}}
<time itemprop="timeRequired" datetime="PT{{ . }}M">{{ $displayTime }}&#160;minute</time> read
2022-06-02 04:49:04 +00:00
{{- end -}}