Order all pages by weight, date, title

This commit is contained in:
Will Faught
2024-06-09 18:55:42 -07:00
parent 7d6da8080e
commit bf692c9842
18 changed files with 121 additions and 121 deletions

View File

@@ -10,7 +10,6 @@
{{ $flags := slice }}
{{ $future := and $page.PublishDate (gt $page.PublishDate now) }}
{{ $modified := and $page.PublishDate $page.Lastmod (lt $page.PublishDate $page.Lastmod) }}
{{ $pinned := $page.Params.paige.pin }}
{{ $readingtime := $page.ReadingTime }}
{{ $series := $page.GetTerms "series" }}
{{ $summary := $page.Summary | markdownify | plainify | htmlUnescape }}
@@ -44,7 +43,7 @@
<div class="{{ $class }}">
{{ with $title }}
<p class="mb-0 paige-title text-center">{{ if $pinned -}} <i class="bi bi-pin-fill text-secondary" style="margin-left: -2.5ch; position: absolute"><span class="visually-hidden">{{ i18n "paige_pinned_page" }}</span></i> {{ end }}<a href="{{ $titlelink }}">{{ . }}</a></p>
<p class="mb-0 paige-title text-center"><a href="{{ $titlelink }}">{{ . }}</a></p>
{{ end }}
{{ with $description }}

View File

@@ -1,92 +1,10 @@
{{ $page := . }}
{{ $collections := slice }}
{{ $h2size := "h4" }}
{{ $manypagegroups := false }}
{{ $pagegroups := slice }}
{{ $pager := false }}
{{ $pages := $page.RegularPages }}
{{ $sections := $page.Sections }}
{{ define "pagination" }}
{{ $params := . }}
{{ range $name, $taxonomy := cond $page.IsHome site.Taxonomies slice }}
{{ if $taxonomy.Page }}
{{ $collections = $collections | append $taxonomy.Page }}
{{ end }}
{{ end }}
{{ if and (not $pages) (in (slice "taxonomy" "term") $page.Kind) }}
{{ $pages = $page.Pages }}
{{ end }}
{{ $pinned := where $pages "Params.paige.pin" true }}
{{ $unpinned := complement $pinned $pages }}
{{ $weighted := where $unpinned "Weight" "gt" 0 }}
{{ if $weighted }}
{{ $h2size = "h5" }}
{{ $pager = $page.Paginate $unpinned.ByWeight }}
{{ else }}
{{ $pager = $page.Paginate ($unpinned.GroupByPublishDate "January 2006") }}
{{ $pagegroups = $pager.PageGroups }}
{{ $manypagegroups = gt (len $pagegroups) 1 }}
{{ if not $manypagegroups }}
{{ $h2size = "h5" }}
{{ end }}
{{ end }}
{{ with $collections }}
<div id="paige-collections">
{{ if or $sections $pages }}
<h2 class="{{ $h2size }} text-center" id="paige-collections-header">{{ i18n "paige_collections" }}</h2>
{{ end }}
{{ range .ByWeight }}
{{ partial "paige/page.html" . }}
{{ end }}
</div>
{{ end }}
{{ with $sections }}
<div id="paige-sections">
{{ if or $collections $pages }}
<h2 class="{{ $h2size }} text-center" id="paige-sections-header">{{ i18n "paige_sections" }}</h2>
{{ end }}
{{ range .ByWeight }}
{{ partial "paige/page.html" . }}
{{ end }}
</div>
{{ end }}
{{ with $pages }}
<div id="paige-pages">
{{ if or $collections $sections }}
<h2 class="{{ $h2size }} text-center" id="paige-pages-header">{{ i18n "paige_pages" }}</h2>
{{ end }}
{{ range $pinned.ByWeight }}
{{ partial "paige/page.html" . }}
{{ end }}
{{ if $pagegroups }}
{{ range $pagegroups }}
{{ if $manypagegroups }}
<h3 class="h5 paige-date-header text-center">{{ .Key }}</h3>
{{ end }}
{{ range .Pages.ByPublishDate.Reverse }}
{{ partial "paige/page.html" . }}
{{ end }}
{{ end }}
{{ else }}
{{ range $pager.Pages }}
{{ partial "paige/page.html" . }}
{{ end }}
{{ end }}
</div>
{{ $page := .page }}
{{ $pager := .pager }}
{{ if or $pager.HasPrev $pager.HasNext }}
<div id="paige-pagination">
@@ -124,3 +42,109 @@
</div>
{{ end }}
{{ end }}
{{ $collections := slice }}
{{ $pages := $page.RegularPages }}
{{ $sections := $page.Sections }}
{{ if $page.IsHome }}
{{ range $name, $taxonomy := site.Taxonomies }}
{{ if $taxonomy.Page }}
{{ $collections = $collections | append $taxonomy.Page }}
{{ end }}
{{ end }}
{{ end }}
{{ if and (not $pages) (in (slice "taxonomy" "term") $page.Kind) }}
{{ $pages = $page.Pages }}
{{ end }}
{{ with $collections }}
{{ $ordered := slice }}
{{ range (.GroupBy "Weight").Reverse }}
{{ range (sort (.Pages.GroupBy "PublishDate") "Key").Reverse }}
{{ range .Pages.ByTitle }}
{{ $ordered = $ordered | append . }}
{{ end }}
{{ end }}
{{ end }}
<div id="paige-collections">
{{ if or $sections $pages }}
<h2 class="h5 text-center" id="paige-collections-header">{{ i18n "paige_collections" }}</h2>
{{ end }}
{{ if or $sections $pages }}
{{ range $ordered }}
{{ partial "paige/page.html" . }}
{{ end }}
{{ else }}
{{ $pager := $page.Paginate $ordered }}
{{ range $pager.Pages }}
{{ partial "paige/page.html" . }}
{{ end }}
{{ template "pagination" (dict "page" $page "pager" $pager) }}
{{ end }}
</div>
{{ end }}
{{ with $sections }}
{{ $ordered := slice }}
{{ range (.GroupBy "Weight").Reverse }}
{{ range (sort (.Pages.GroupBy "PublishDate") "Key").Reverse }}
{{ range .Pages.ByTitle }}
{{ $ordered = $ordered | append . }}
{{ end }}
{{ end }}
{{ end }}
<div id="paige-sections">
{{ if or $collections $pages }}
<h2 class="h5 text-center" id="paige-sections-header">{{ i18n "paige_sections" }}</h2>
{{ end }}
{{ if $pages }}
{{ range $ordered }}
{{ partial "paige/page.html" . }}
{{ end }}
{{ else }}
{{ $pager := $page.Paginate $ordered }}
{{ range $pager.Pages }}
{{ partial "paige/page.html" . }}
{{ end }}
{{ template "pagination" (dict "page" $page "pager" $pager) }}
{{ end }}
</div>
{{ end }}
{{ with $pages }}
{{ $ordered := slice }}
{{ range ($pages.GroupBy "Weight").Reverse }}
{{ range (sort (.Pages.GroupBy "PublishDate") "Key").Reverse }}
{{ range .Pages.ByTitle }}
{{ $ordered = $ordered | append . }}
{{ end }}
{{ end }}
{{ end }}
<div id="paige-pages">
{{ if or $collections $sections }}
<h2 class="h5 text-center" id="paige-pages-header">{{ i18n "paige_pages" }}</h2>
{{ end }}
{{ $pager := $page.Paginate $ordered }}
{{ range $pager.Pages }}
{{ partial "paige/page.html" . }}
{{ end }}
{{ template "pagination" (dict "page" $page "pager" $pager) }}
</div>
{{ end }}