Add page reading time

master
Will Faught 2 years ago
parent 32031a6e20
commit e7ce63f42f

@ -274,6 +274,9 @@ paige:
description: description:
class: "lead text-center" # Default is "lead text-center" class: "lead text-center" # Default is "lead text-center"
hide: false # Default is false hide: false # Default is false
reading_time:
class: "text-center text-secondary" # Default is "text-center text-secondary"
show: false # Default is false
title: title:
class: "display-5 fw-bold text-center" # Default is "display-5 fw-bold text-center" class: "display-5 fw-bold text-center" # Default is "display-5 fw-bold text-center"
hide: false # Default is false hide: false # Default is false
@ -291,6 +294,9 @@ paige:
description: description:
class: "text-center" # Default is "text-center" class: "text-center" # Default is "text-center"
hide: false # Default is false hide: false # Default is false
reading_time:
class: "text-center text-secondary" # Default is "text-center text-secondary"
show: false # Default is false
summary: summary:
class: "text-center" # Default is "text-center" class: "text-center" # Default is "text-center"
show: false # Default is false show: false # Default is false

@ -1,6 +1,10 @@
paige_figure: paige_figure:
other: Figure other: Figure
paige_minutes:
one: minute
other: minutes
paige_noscript: paige_noscript:
other: JavaScript is required. other: JavaScript is required.

@ -5,12 +5,17 @@
{{ $gap := "mb-0" }} {{ $gap := "mb-0" }}
{{ $date := cond ($page.Param "paige.page.date.hide" | not) $page.PublishDate "" }} {{ $date := cond ($page.Param "paige.page.date.hide" | not) $page.PublishDate "" }}
{{ $dateclass := $page.Param "paige.page.date.class" | default "text-center text-secondary" }} {{ $dateclass := $page.Param "paige.page.date.class" | default "text-center text-secondary" }}
{{ $readingtime := $page.Param "paige.page.reading_time.show" }}
{{ $readingtimeclass := $page.Param "paige.page.reading_time.class" | default "text-center text-secondary" }}
{{ with $authors }} {{ with $authors }}
<p class="{{ if $date }} {{ $gap }} {{ end }} {{ $authorsclass }}">{{ . }}</p> <p class="{{ if or $date $readingtime }} {{ $gap }} {{ end }} {{ $authorsclass }}">{{ . }}</p>
{{ end }} {{ end }}
{{ with $date }} {{ with $date }}
<p class="{{ $dateclass }}"> <p class="{{ if $readingtime }} {{ $gap }} {{ end }} {{ $dateclass }}">
<time datetime="{{ .Format `2006-01-02` }}">{{ time.Format ($page.Param "paige.page.date.format" | default ":date_long") . }}</time> <time datetime="{{ .Format `2006-01-02` }}">{{ time.Format ($page.Param "paige.page.date.format" | default ":date_long") . }}</time>
</p> </p>
{{ end }} {{ end }}
{{ if $readingtime }}
<p class="{{ $readingtimeclass }}">{{ $page.ReadingTime }} {{ i18n "paige_minutes" $page.ReadingTime }}</p>
{{ end }}

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

Loading…
Cancel
Save