From da568809cab2c5d2bd1a44093ad0cbb2a3176bca Mon Sep 17 00:00:00 2001 From: Will Faught Date: Tue, 4 Jun 2024 21:27:28 -0700 Subject: [PATCH] Shrink list page headers if possible --- layouts/partials/paige/pages.html | 53 +++++++++++++++++++------------ 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/layouts/partials/paige/pages.html b/layouts/partials/paige/pages.html index 3f648314..b53c8d4d 100644 --- a/layouts/partials/paige/pages.html +++ b/layouts/partials/paige/pages.html @@ -1,7 +1,11 @@ {{ $page := . }} {{ $collections := slice }} +{{ $h2size := "h4" }} +{{ $manypagegroups := false }} {{ $sections := where $page.Pages "Kind" "section" }} +{{ $pagegroups := slice }} +{{ $pager := false }} {{ $pages := where $page.Pages "Kind" "in" (slice "page" "term") }} {{ range $name, $taxonomy := cond $page.IsHome site.Taxonomies slice }} @@ -10,10 +14,29 @@ {{ end }} {{ 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 }}
{{ if or $sections $pages }} -

{{ i18n "paige_collections" }}

+

{{ i18n "paige_collections" }}

{{ end }} {{ range . }} @@ -25,7 +48,7 @@ {{ with $sections }}
{{ if or $collections $pages }} -

{{ i18n "paige_sections" }}

+

{{ i18n "paige_sections" }}

{{ end }} {{ range . }} @@ -37,32 +60,16 @@ {{ with $pages }}
{{ if or $collections $sections }} -

{{ i18n "paige_pages" }}

+

{{ i18n "paige_pages" }}

{{ end }} - {{ $pinned := where . "Params.paige.pin" true }} - {{ range $pinned.ByPublishDate.Reverse }} {{ partial "paige/page.html" . }} {{ end }} - {{ $pager := false }} - {{ $unpinned := complement $pinned . }} - {{ $weighted := where $unpinned "Weight" "gt" 0 }} - - {{ if $weighted }} - {{ $pager = $page.Paginate $unpinned.ByWeight }} - - {{ range $pager.Pages }} - {{ partial "paige/page.html" . }} - {{ end }} - {{ else }} - {{ $pager = $page.Paginate ($unpinned.GroupByPublishDate "January 2006") }} - - {{ $pagegroups := $pager.PageGroups }} - + {{ if $pagegroups }} {{ range $pagegroups }} - {{ if gt (len $pagegroups) 1 }} + {{ if $manypagegroups }}

{{ .Key }}

{{ end }} @@ -70,6 +77,10 @@ {{ partial "paige/page.html" . }} {{ end }} {{ end }} + {{ else }} + {{ range $pager.Pages }} + {{ partial "paige/page.html" . }} + {{ end }} {{ end }}