Add page reading time

This commit is contained in:
Will Faught
2023-01-29 16:10:39 -08:00
parent 32031a6e20
commit e7ce63f42f
4 changed files with 26 additions and 6 deletions

View File

@@ -34,6 +34,8 @@
{{ $descriptionclass := $page.Param "paige.page_list.description.class" | default $class }}
{{ $flags := slice }}
{{ $gap := "mb-0" }}
{{ $readingtime := $page.Param "paige.page_list.reading_time.show" }}
{{ $readingtimeclass := $page.Param "paige.page_list.reading_time.class" | default "text-center text-secondary" }}
{{ $summary := cond ($page.Param "paige.page_list.summary.show" | not) "" (.Summary | strings.TrimPrefix "<p>" | strings.TrimSuffix "</p>") }}
{{ $summaryclass := $page.Param "paige.page_list.summary.class" | default $class }}
{{ $title := cond ($page.Param "paige.page_list.title.hide" | not) (.Title | markdownify) "" }}
@@ -57,20 +59,23 @@
{{ $flags = delimit ($flags | sort | uniq) " " }}
<p class="{{ if or $description $authors $date $summary }} {{ $gap }} {{ end }} {{ with $flags }} {{ . }} {{ end }} {{ $titleclass }}">
<p class="{{ if or $description $authors $date $readingtime $summary }} {{ $gap }} {{ end }} {{ with $flags }} {{ . }} {{ end }} {{ $titleclass }}">
<a href="{{ .RelPermalink }}">{{ $title | markdownify }}</a>
</p>
{{ with $description }}
<p class="{{ if or $authors $date $summary }} {{ $gap }} {{ end }} {{ $descriptionclass }}">{{ . }}</p>
<p class="{{ if or $authors $date $readingtime $summary }} {{ $gap }} {{ end }} {{ $descriptionclass }}">{{ . }}</p>
{{ end }}
{{ with $authors }}
<p class="{{ if or $date $summary }} {{ $gap }} {{ end }} {{ $authorsclass }}">{{ . }}</p>
<p class="{{ if or $date $readingtime $summary }} {{ $gap }} {{ end }} {{ $authorsclass }}">{{ . }}</p>
{{ end }}
{{ if $date }}
<p class="{{ if $summary }} {{ $gap }} {{ end }} {{ $dateclass }}">
<p class="{{ if or $readingtime $summary }} {{ $gap }} {{ end }} {{ $dateclass }}">
<time datetime="{{ $date.Format `2006-01-02` }}">{{ time.Format (.Param "paige.page_list.date.format" | default ":date_long") $date }}</time>
</p>
{{ end }}
{{ if $readingtime }}
<p class="{{ if $summary }} {{ $gap }} {{ end }} {{ $readingtimeclass }}">{{ .ReadingTime }} {{ i18n "paige_minutes" .ReadingTime }}</p>
{{ end }}
{{ if $summary }}
<p class="{{ $summaryclass }}">{{ $summary }}</p>
{{ end }}