Skip to content

Commit

Permalink
Order weighted pages ascending before non-weighted pages
Browse files Browse the repository at this point in the history
  • Loading branch information
willfaught committed Jun 13, 2024
1 parent 7d5fe96 commit 2911e86
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 11 deletions.
2 changes: 1 addition & 1 deletion exampleSite/content/content/alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ paige:
type: "primary"
tags: ["alerts"]
title: "Alert"
weight: 30
weight: 60
---

This page has the following parameters:
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/content/emoji-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: 40
weight: 50
---

<!--
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/content/link.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: "A front matter link."
link: "https://willfaught.com/paige"
tags: ["link"]
title: "Link"
weight: 20
weight: 70
---

It takes you to the home page.
2 changes: 1 addition & 1 deletion exampleSite/content/content/markdown-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: 80
weight: 10
---

<!--
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/content/math-typesetting.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ paige:
math: true
tags: ["katex", "math", "typesetting"]
title: "Math Typesetting"
weight: 50
weight: 40
---

<!--
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/content/placeholder-text.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ paige:
hide_page: true
tags: ["markdown", "text"]
title: "Placeholder Text"
weight: 60
weight: 30
---

<!--
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/content/rich-content.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ paige:
hide_page: true
tags: ["shortcodes", "privacy"]
title: "Rich Content"
weight: 70
weight: 20
---

<!--
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/content/video.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ date: "2023-09-24T21:29:31-07:00"
description: "Only a video."
tags: ["video"]
title: "Video"
weight: 10
weight: 80
---

{{< paige/youtube "dQw4w9WgXcQ" >}}
30 changes: 27 additions & 3 deletions layouts/partials/paige/pages.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,16 @@

{{ with $collections }}
{{ $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 .Pages.ByTitle }}
{{ $ordered = $ordered | append . }}
Expand Down Expand Up @@ -93,8 +101,16 @@ <h2 class="h5 text-center" id="paige-collections-header">{{ i18n "paige_collecti

{{ with $sections }}
{{ $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 .Pages.ByTitle }}
{{ $ordered = $ordered | append . }}
Expand Down Expand Up @@ -125,8 +141,16 @@ <h2 class="h5 text-center" id="paige-sections-header">{{ i18n "paige_sections" }

{{ with $pages }}
{{ $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 .Pages.ByTitle }}
{{ $ordered = $ordered | append . }}
Expand Down

0 comments on commit 2911e86

Please sign in to comment.