Order all pages by weight, date, title

master
Will Faught 1 year ago
parent 7d6da8080e
commit bf692c9842

@ -297,9 +297,6 @@ Parameters specific to pages:
```toml
link = "https://youtu.be/dQw4w9WgXcQ" # The reference for an anchor around the title
[paige]
pin = true # Order this page before the rest
[paige.alert]
message = "Alert!" # Markdown displayed before the page body
type = "primary" # Bootstrap alert class
@ -943,8 +940,6 @@ Page and sub-page classes:
<dd>The authors.</dd>
<dt><code>.paige-date</code></dt>
<dd>The date.</dd>
<dt><code>.paige-date-header</code></dt>
<dd>The date headers.</dd>
<dt><code>.paige-description</code></dt>
<dd>The description.</dd>
<dt><code>.paige-keyword</code></dt>

@ -9,7 +9,7 @@ paige:
type: "primary"
tags: ["alerts"]
title: "Alert"
weight: 60
weight: 30
---
This page has the following parameters:

@ -5,7 +5,7 @@ date: "2023-09-18T21:32:40-07:00"
description: "Guide to emoji usage in Hugo."
tags: ["emoji"]
title: "Emoji Support"
weight: 50
weight: 40
---
<!--

@ -6,7 +6,7 @@ description: "A front matter link."
link: "https://willfaught.com/paige"
tags: ["link"]
title: "Link"
weight: 70
weight: 20
---
It takes you to the home page.

@ -5,7 +5,7 @@ date: "2023-09-18T21:32:52-07:00"
description: "Sample article showcasing basic Markdown syntax and formatting for HTML elements."
tags: ["markdown", "css", "html"]
title: "Markdown Syntax Guide"
weight: 10
weight: 80
---
<!--

@ -7,7 +7,7 @@ paige:
math: true
tags: ["katex", "math", "typesetting"]
title: "Math Typesetting"
weight: 40
weight: 50
---
<!--

@ -8,7 +8,7 @@ paige:
hide_page: true
tags: ["markdown", "text"]
title: "Placeholder Text"
weight: 30
weight: 60
---
<!--

@ -8,7 +8,7 @@ paige:
hide_page: true
tags: ["shortcodes", "privacy"]
title: "Rich Content"
weight: 20
weight: 70
---
<!--

@ -5,7 +5,7 @@ date: "2023-09-24T21:29:31-07:00"
description: "Only a video."
tags: ["video"]
title: "Video"
weight: 80
weight: 10
---
{{< paige/youtube "dQw4w9WgXcQ" >}}

@ -14,7 +14,6 @@ paige:
#paige-toc,
.paige-authors,
.paige-date,
.paige-date-header,
.paige-keywords,
.paige-reading-time,
.paige-series,
@ -49,7 +48,6 @@ paige:
#paige-toc,
.paige-authors,
.paige-date,
.paige-date-header,
.paige-keywords,
.paige-reading-time,
.paige-series,

@ -16,7 +16,6 @@ paige:
#paige-toc,
.paige-authors,
.paige-date,
.paige-date-header,
.paige-keywords,
.paige-reading-time,
.paige-series,
@ -26,7 +25,7 @@ paige:
series: ["series-demo"]
tags: ["show", "singles"]
title: "Show Data"
weight: 10
weight: 20
---
This site hides some single page data by default. This page shows it all.
@ -53,7 +52,6 @@ paige:
#paige-toc,
.paige-authors,
.paige-date,
.paige-date-header,
.paige-keywords,
.paige-reading-time,
.paige-series,

@ -16,7 +16,6 @@ paige:
#paige-toc,
.paige-authors,
.paige-date,
.paige-date-header,
.paige-keywords,
.paige-reading-time,
.paige-series,
@ -37,14 +36,13 @@ paige:
#paige-credit { font-style: italic; }
.paige-authors { font-style: italic; }
.paige-date { font-style: italic; }
.paige-date-header { font-style: italic; }
.paige-keyword { font-style: italic; }
.paige-series { font-style: italic; }
.paige-summary { font-style: italic; }
series: ["series-demo"]
tags: ["singles", "style"]
title: "Style Data"
weight: 20
weight: 10
---
This site uses the default styles on the other pages. This page changes them.
@ -71,7 +69,6 @@ paige:
#paige-toc,
.paige-authors,
.paige-date,
.paige-date-header,
.paige-keywords,
.paige-reading-time,
.paige-series,
@ -92,7 +89,6 @@ paige:
#paige-credit { font-style: italic; }
.paige-authors { font-style: italic; }
.paige-date { font-style: italic; }
.paige-date-header { font-style: italic; }
.paige-keyword { font-style: italic; }
.paige-series { font-style: italic; }
.paige-summary { font-style: italic; }

@ -10,7 +10,6 @@
#paige-toc,
.paige-authors,
.paige-date,
.paige-date-header,
.paige-keywords,
.paige-reading-time,
.paige-series,

@ -20,9 +20,6 @@ paige_noscript:
paige_pages:
other: Seiten
paige_pinned_page:
other: Angeheftete seite
paige_search_button:
other: Suche

@ -38,9 +38,6 @@ paige_page_list_navigation:
paige_pages:
other: Pages
paige_pinned_page:
other: Pinned page
paige_previous:
other: Previous

@ -20,9 +20,6 @@ paige_noscript:
paige_pages:
other: 页数
paige_pinned_page:
other: 固定页面
paige_search_button:
other: 搜索

@ -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 }}

@ -1,126 +1,150 @@
{{ $page := . }}
{{ define "pagination" }}
{{ $params := . }}
{{ $page := .page }}
{{ $pager := .pager }}
{{ if or $pager.HasPrev $pager.HasNext }}
<div id="paige-pagination">
<div class="d-flex justify-content-center">
<nav aria-label="{{ i18n `paige_page_list_navigation` }}">
<ul class="pagination">
{{ with $page.Paginator }}
{{ if and (ne .PageNumber .First.PageNumber) (ne .First.PageNumber .Prev.PageNumber) }}
<li class="page-item">
<a aria-label="{{ i18n `paige_first` }}" class="page-link" href="{{ .First.URL }}"><span aria-hidden="true">&laquo;</span></a>
</li>
{{ end }}
{{ with .Prev }}
<li class="page-item">
<a aria-label="{{ i18n `paige_previous` }}" class="page-link" href="{{ .URL }}"><span aria-hidden="true">&lsaquo;</span></a>
</li>
{{ end }}
{{ with .Next }}
<li class="page-item">
<a aria-label="{{ i18n `paige_next` }}" class="page-link" href="{{ .URL }}"><span aria-hidden="true">&rsaquo;</span></a>
</li>
{{ end }}
{{ if and (ne .PageNumber .Last.PageNumber) (ne .Last.PageNumber .Next.PageNumber) }}
<li class="page-item">
<a aria-label="{{ i18n `paige_last` }}" class="page-link" href="{{ .Last.URL }}"><span aria-hidden="true">&raquo;</span></a>
</li>
{{ end }}
{{ end }}
</ul>
</nav>
</div>
</div>
{{ end }}
{{ end }}
{{ $collections := slice }}
{{ $h2size := "h4" }}
{{ $manypagegroups := false }}
{{ $pagegroups := slice }}
{{ $pager := false }}
{{ $pages := $page.RegularPages }}
{{ $sections := $page.Sections }}
{{ range $name, $taxonomy := cond $page.IsHome site.Taxonomies slice }}
{{ 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 }}
{{ $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 }}
{{ with $collections }}
{{ $ordered := slice }}
{{ if not $manypagegroups }}
{{ $h2size = "h5" }}
{{ range (.GroupBy "Weight").Reverse }}
{{ range (sort (.Pages.GroupBy "PublishDate") "Key").Reverse }}
{{ range .Pages.ByTitle }}
{{ $ordered = $ordered | append . }}
{{ end }}
{{ end }}
{{ 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>
<h2 class="h5 text-center" id="paige-collections-header">{{ i18n "paige_collections" }}</h2>
{{ end }}
{{ range .ByWeight }}
{{ if or $sections $pages }}
{{ range $ordered }}
{{ partial "paige/page.html" . }}
{{ end }}
</div>
{{ end }}
{{ else }}
{{ $pager := $page.Paginate $ordered }}
{{ with $sections }}
<div id="paige-sections">
{{ if or $collections $pages }}
<h2 class="{{ $h2size }} text-center" id="paige-sections-header">{{ i18n "paige_sections" }}</h2>
{{ range $pager.Pages }}
{{ partial "paige/page.html" . }}
{{ end }}
{{ range .ByWeight }}
{{ partial "paige/page.html" . }}
{{ template "pagination" (dict "page" $page "pager" $pager) }}
{{ 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 }}
{{ with $sections }}
{{ $ordered := slice }}
{{ range $pinned.ByWeight }}
{{ partial "paige/page.html" . }}
{{ range (.GroupBy "Weight").Reverse }}
{{ range (sort (.Pages.GroupBy "PublishDate") "Key").Reverse }}
{{ range .Pages.ByTitle }}
{{ $ordered = $ordered | append . }}
{{ end }}
{{ end }}
{{ end }}
{{ if $pagegroups }}
{{ range $pagegroups }}
{{ if $manypagegroups }}
<h3 class="h5 paige-date-header text-center">{{ .Key }}</h3>
<div id="paige-sections">
{{ if or $collections $pages }}
<h2 class="h5 text-center" id="paige-sections-header">{{ i18n "paige_sections" }}</h2>
{{ end }}
{{ range .Pages.ByPublishDate.Reverse }}
{{ if $pages }}
{{ range $ordered }}
{{ partial "paige/page.html" . }}
{{ end }}
{{ end }}
{{ else }}
{{ $pager := $page.Paginate $ordered }}
{{ range $pager.Pages }}
{{ partial "paige/page.html" . }}
{{ end }}
{{ template "pagination" (dict "page" $page "pager" $pager) }}
{{ end }}
</div>
{{ end }}
{{ if or $pager.HasPrev $pager.HasNext }}
<div id="paige-pagination">
<div class="d-flex justify-content-center">
<nav aria-label="{{ i18n `paige_page_list_navigation` }}">
<ul class="pagination">
{{ with $page.Paginator }}
{{ if and (ne .PageNumber .First.PageNumber) (ne .First.PageNumber .Prev.PageNumber) }}
<li class="page-item">
<a aria-label="{{ i18n `paige_first` }}" class="page-link" href="{{ .First.URL }}"><span aria-hidden="true">&laquo;</span></a>
</li>
{{ end }}
{{ with $pages }}
{{ $ordered := slice }}
{{ with .Prev }}
<li class="page-item">
<a aria-label="{{ i18n `paige_previous` }}" class="page-link" href="{{ .URL }}"><span aria-hidden="true">&lsaquo;</span></a>
</li>
{{ range ($pages.GroupBy "Weight").Reverse }}
{{ range (sort (.Pages.GroupBy "PublishDate") "Key").Reverse }}
{{ range .Pages.ByTitle }}
{{ $ordered = $ordered | append . }}
{{ end }}
{{ end }}
{{ with .Next }}
<li class="page-item">
<a aria-label="{{ i18n `paige_next` }}" class="page-link" href="{{ .URL }}"><span aria-hidden="true">&rsaquo;</span></a>
</li>
{{ end }}
{{ if and (ne .PageNumber .Last.PageNumber) (ne .Last.PageNumber .Next.PageNumber) }}
<li class="page-item">
<a aria-label="{{ i18n `paige_last` }}" class="page-link" href="{{ .Last.URL }}"><span aria-hidden="true">&raquo;</span></a>
</li>
<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 }}
</ul>
</nav>
</div>
{{ template "pagination" (dict "page" $page "pager" $pager) }}
</div>
{{ end }}
{{ end }}

Loading…
Cancel
Save