From 811fe0bbed613d0e508abd11a627e48c65b2425f Mon Sep 17 00:00:00 2001 From: Will Faught Date: Sun, 5 Mar 2023 13:13:18 -0800 Subject: [PATCH] Add pinned pages --- README.md | 1 + layouts/partials/paige/pages.html | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index dc07e53f..0075d0c3 100644 --- a/README.md +++ b/README.md @@ -390,6 +390,7 @@ authors: link: "https://youtu.be/dQw4w9WgXcQ" # The reference for an anchor around the title paige: alert: "Alert!" # Markdown displayed before the page body (defaults to primary alert type) + pin: true # Display this page before the rest paige: alert: message: "Alert!" # Markdown displayed before the page body diff --git a/layouts/partials/paige/pages.html b/layouts/partials/paige/pages.html index c2b697da..4f492b34 100644 --- a/layouts/partials/paige/pages.html +++ b/layouts/partials/paige/pages.html @@ -2,13 +2,13 @@ {{ if $page.Pages }} {{ if $page.Param "paige.section_pages.full_pages" }} - {{ $p := $page.Paginate $page.Pages }} + {{ $pager := $page.Paginate $page.Pages }}
- {{ range $p.Pages }} + {{ range $pager.Pages }} {{ partial "paige/article.html" (dict "fullpages" true "page" .) }} {{ end }}
- {{ if or $p.HasPrev $p.HasNext }} + {{ if or $pager.HasPrev $pager.HasNext }}
{{ partial "paige/pagination.html" $page }} @@ -17,18 +17,21 @@ {{ end }} {{ else }}
- {{ range (where $page.Pages "Params.paige.pin" true).ByPublishDate.Reverse }} + {{ $pinned := where $page.Pages "Params.paige.pin" true }} + {{ range $pinned.ByPublishDate.Reverse }} {{ partial "paige/page.html" . }} {{ end }} - {{ $p := $page.Paginate ($page.Pages.ByPublishDate.Reverse.GroupByPublishDate "January 2006") }} - {{ range $p.PageGroups }} + {{ $unpinned := complement $pinned $page.Pages }} + {{ $pagegroups := $unpinned.ByPublishDate.Reverse.GroupByPublishDate "January 2006" }} + {{ $pager := $page.Paginate $pagegroups }} + {{ range $pager.PageGroups }}

{{ .Key }}

{{ range .Pages }} {{ partial "paige/page.html" . }} {{ end }} {{ end }}
- {{ if or $p.HasPrev $p.HasNext }} + {{ if or $pager.HasPrev $pager.HasNext }}
{{ partial "paige/pagination.html" $page }}