Issue #697: Add setting order_sections_by_date

This commit is contained in:
Michael Wyraz 2024-07-18 15:30:48 +02:00
parent 33fbda0e9d
commit 4daa6044e6
2 changed files with 8 additions and 0 deletions

View File

@ -36,6 +36,9 @@ enableRobotsTXT = true
background_color_class = "bg-black" background_color_class = "bg-black"
recent_posts_number = 3 recent_posts_number = 3
# Sort sections by date (oldest first)
#order_sections_by_date = true
[[params.ananke_socials]] [[params.ananke_socials]]
name = "twitter" name = "twitter"
url = "https://twitter.com/GoHugoIO" url = "https://twitter.com/GoHugoIO"

View File

@ -11,6 +11,11 @@
{{ $section_name := . }} {{ $section_name := . }}
{{/* Create a variable with that section to use in multiple places. */}} {{/* Create a variable with that section to use in multiple places. */}}
{{ $section := where $.Site.RegularPages "Section" "in" $section_name }} {{ $section := where $.Site.RegularPages "Section" "in" $section_name }}
{{ if $.Site.Params.order_sections_by_date | default false }}
{{ $section = $section.ByDate }}
{{ end }}
{{ $section_count := len $section }} {{ $section_count := len $section }}
{{ if ge $section_count 1 }} {{ if ge $section_count 1 }}
<div class="pa3 pa4-ns w-100 w-70-ns center"> <div class="pa3 pa4-ns w-100 w-70-ns center">