From 4daa6044e6a2de990683c3f31236394211f72140 Mon Sep 17 00:00:00 2001 From: Michael Wyraz Date: Thu, 18 Jul 2024 15:30:48 +0200 Subject: [PATCH] Issue #697: Add setting `order_sections_by_date` --- exampleSite/config.toml | 3 +++ layouts/index.html | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index cd3325cf7..4e0d6e66b 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -36,6 +36,9 @@ enableRobotsTXT = true background_color_class = "bg-black" recent_posts_number = 3 + # Sort sections by date (oldest first) + #order_sections_by_date = true + [[params.ananke_socials]] name = "twitter" url = "https://twitter.com/GoHugoIO" diff --git a/layouts/index.html b/layouts/index.html index 4b826a11f..68fada25f 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -11,6 +11,11 @@ {{ $section_name := . }} {{/* Create a variable with that section to use in multiple places. */}} {{ $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 }} {{ if ge $section_count 1 }}