Add page categories

master
Will Faught 2 years ago
parent e7ce63f42f
commit 98ae0e4658

@ -264,6 +264,9 @@ paige:
authors:
class: "text-center text-secondary" # Default is "text-center text-secondary"
hide: false # Default is false
categories:
class: "badge text-bg-secondary text-decoration-none" # Default is "badge text-bg-secondary text-decoration-none"
show: false # Default is false
content:
class: "" # Default is ""
hide: false # Default is false
@ -284,6 +287,9 @@ paige:
authors:
class: "text-center text-secondary" # Default is "text-center text-secondary"
show: false # Default is false
categories:
class: "badge text-bg-secondary text-decoration-none" # Default is "badge text-bg-secondary text-decoration-none"
show: false # Default is false
date:
class: "text-center text-secondary" # Default is "text-center text-secondary"
format: ":date_long" # Default is ":date_long"

@ -2,6 +2,8 @@
{{ $authors := cond ($page.Param "paige.page.authors.hide" | not) (partial "paige/func-authors.html" $page) "" }}
{{ $authorsclass := $page.Param "paige.page.authors.class" | default "text-center text-secondary" }}
{{ $categories := cond ($page.Param "paige.page.categories.show" | not) slice ($page.Params.categories | default slice) | sort | uniq }}
{{ $categoriesclass := $page.Param "paige.page.categories.class" | default "badge text-bg-secondary text-decoration-none" }}
{{ $gap := "mb-0" }}
{{ $date := cond ($page.Param "paige.page.date.hide" | not) $page.PublishDate "" }}
{{ $dateclass := $page.Param "paige.page.date.class" | default "text-center text-secondary" }}
@ -9,13 +11,20 @@
{{ $readingtimeclass := $page.Param "paige.page.reading_time.class" | default "text-center text-secondary" }}
{{ with $authors }}
<p class="{{ if or $date $readingtime }} {{ $gap }} {{ end }} {{ $authorsclass }}">{{ . }}</p>
<p class="{{ if or $date $readingtime $categories }} {{ $gap }} {{ end }} {{ $authorsclass }}">{{ . }}</p>
{{ end }}
{{ with $date }}
<p class="{{ if $readingtime }} {{ $gap }} {{ end }} {{ $dateclass }}">
<p class="{{ if or $readingtime $categories }} {{ $gap }} {{ end }} {{ $dateclass }}">
<time datetime="{{ .Format `2006-01-02` }}">{{ time.Format ($page.Param "paige.page.date.format" | default ":date_long") . }}</time>
</p>
{{ end }}
{{ if $readingtime }}
<p class="{{ $readingtimeclass }}">{{ $page.ReadingTime }} {{ i18n "paige_minutes" $page.ReadingTime }}</p>
<p class="{{ if $categories }} {{ $gap }} {{ end }} {{ $readingtimeclass }}">{{ $page.ReadingTime }} {{ i18n "paige_minutes" $page.ReadingTime }}</p>
{{ end }}
{{ with $categories }}
<p class="text-center">
{{ range . }}
<a class="{{ $categoriesclass }}" href="{{ relLangURL (printf `categories/%v/` .) | safeURL }}">{{ . }}</a>
{{ end }}
</p>
{{ end }}

@ -28,6 +28,8 @@
{{ $authors := cond ($page.Param "paige.page_list.authors.show" | not) "" (partial "paige/func-authors.html" .) }}
{{ $authorsclass := $page.Param "paige.page_list.authors.class" | default (print $class " text-secondary") }}
{{ $categories := cond ($page.Param "paige.page_list.categories.show" | not) slice (.Params.categories | default slice) | sort | uniq }}
{{ $categoriesclass := $page.Param "paige.page_list.categories.class" | default "badge text-bg-secondary text-decoration-none" }}
{{ $date := cond ($page.Param "paige.page_list.date.show" | not) "" .PublishDate }}
{{ $dateclass := $page.Param "paige.page_list.date.class" | default (print $class " text-secondary") }}
{{ $description := cond ($page.Param "paige.page_list.description.hide" | not) (.Description | markdownify) "" }}
@ -59,22 +61,29 @@
{{ $flags = delimit ($flags | sort | uniq) " " }}
<p class="{{ if or $description $authors $date $readingtime $summary }} {{ $gap }} {{ end }} {{ with $flags }} {{ . }} {{ end }} {{ $titleclass }}">
<p class="{{ if or $description $authors $date $readingtime $categories $summary }} {{ $gap }} {{ end }} {{ with $flags }} {{ . }} {{ end }} {{ $titleclass }}">
<a href="{{ .RelPermalink }}">{{ $title | markdownify }}</a>
</p>
{{ with $description }}
<p class="{{ if or $authors $date $readingtime $summary }} {{ $gap }} {{ end }} {{ $descriptionclass }}">{{ . }}</p>
<p class="{{ if or $authors $date $readingtime $categories $summary }} {{ $gap }} {{ end }} {{ $descriptionclass }}">{{ . }}</p>
{{ end }}
{{ with $authors }}
<p class="{{ if or $date $readingtime $summary }} {{ $gap }} {{ end }} {{ $authorsclass }}">{{ . }}</p>
<p class="{{ if or $date $readingtime $categories $summary }} {{ $gap }} {{ end }} {{ $authorsclass }}">{{ . }}</p>
{{ end }}
{{ if $date }}
<p class="{{ if or $readingtime $summary }} {{ $gap }} {{ end }} {{ $dateclass }}">
<p class="{{ if or $readingtime $categories $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>
<p class="{{ if or $categories $summary }} {{ $gap }} {{ end }} {{ $readingtimeclass }}">{{ .ReadingTime }} {{ i18n "paige_minutes" .ReadingTime }}</p>
{{ end }}
{{ with $categories }}
<p class="{{ if $summary }} {{ $gap }} {{ end }} text-center">
{{ range . }}
<a class="{{ $categoriesclass }}" href="{{ relLangURL (printf `categories/%v/` .) | safeURL }}">{{ . }}</a>
{{ end }}
</p>
{{ end }}
{{ if $summary }}
<p class="{{ $summaryclass }}">{{ $summary }}</p>

Loading…
Cancel
Save