Order weighted pages ascending before non-weighted pages

master
Will Faught 1 year ago
parent 7d5fe96ce0
commit 2911e8600b

@ -9,7 +9,7 @@ paige:
type: "primary" type: "primary"
tags: ["alerts"] tags: ["alerts"]
title: "Alert" title: "Alert"
weight: 30 weight: 60
--- ---
This page has the following parameters: 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." description: "Guide to emoji usage in Hugo."
tags: ["emoji"] tags: ["emoji"]
title: "Emoji Support" title: "Emoji Support"
weight: 40 weight: 50
--- ---
<!-- <!--

@ -6,7 +6,7 @@ description: "A front matter link."
link: "https://willfaught.com/paige" link: "https://willfaught.com/paige"
tags: ["link"] tags: ["link"]
title: "Link" title: "Link"
weight: 20 weight: 70
--- ---
It takes you to the home page. 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." description: "Sample article showcasing basic Markdown syntax and formatting for HTML elements."
tags: ["markdown", "css", "html"] tags: ["markdown", "css", "html"]
title: "Markdown Syntax Guide" title: "Markdown Syntax Guide"
weight: 80 weight: 10
--- ---
<!-- <!--

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

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

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

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

@ -61,8 +61,16 @@
{{ with $collections }} {{ with $collections }}
{{ $ordered := slice }} {{ $ordered := slice }}
{{ $weights := .GroupBy "Weight" }}
{{ range (.GroupBy "Weight").Reverse }} {{ range $i, $e := $weights }}
{{ if eq $e.Key 0 }}
{{ $weights = slice | append (first $i $weights) | append (after (add $i 1) $weights) | append $e }}
{{ break }}
{{ end }}
{{ end }}
{{ range $weights }}
{{ range (sort (.Pages.GroupBy "PublishDate") "Key").Reverse }} {{ range (sort (.Pages.GroupBy "PublishDate") "Key").Reverse }}
{{ range .Pages.ByTitle }} {{ range .Pages.ByTitle }}
{{ $ordered = $ordered | append . }} {{ $ordered = $ordered | append . }}
@ -93,8 +101,16 @@
{{ with $sections }} {{ with $sections }}
{{ $ordered := slice }} {{ $ordered := slice }}
{{ $weights := .GroupBy "Weight" }}
{{ range (.GroupBy "Weight").Reverse }} {{ range $i, $e := $weights }}
{{ if eq $e.Key 0 }}
{{ $weights = slice | append (first $i $weights) | append (after (add $i 1) $weights) | append $e }}
{{ break }}
{{ end }}
{{ end }}
{{ range $weights }}
{{ range (sort (.Pages.GroupBy "PublishDate") "Key").Reverse }} {{ range (sort (.Pages.GroupBy "PublishDate") "Key").Reverse }}
{{ range .Pages.ByTitle }} {{ range .Pages.ByTitle }}
{{ $ordered = $ordered | append . }} {{ $ordered = $ordered | append . }}
@ -125,8 +141,16 @@
{{ with $pages }} {{ with $pages }}
{{ $ordered := slice }} {{ $ordered := slice }}
{{ $weights := .GroupBy "Weight" }}
{{ range $i, $e := $weights }}
{{ if eq $e.Key 0 }}
{{ $weights = slice | append (first $i $weights) | append (after (add $i 1) $weights) | append $e }}
{{ break }}
{{ end }}
{{ end }}
{{ range ($pages.GroupBy "Weight").Reverse }} {{ range $weights }}
{{ range (sort (.Pages.GroupBy "PublishDate") "Key").Reverse }} {{ range (sort (.Pages.GroupBy "PublishDate") "Key").Reverse }}
{{ range .Pages.ByTitle }} {{ range .Pages.ByTitle }}
{{ $ordered = $ordered | append . }} {{ $ordered = $ordered | append . }}

Loading…
Cancel
Save