From: Danilo M. Date: Sun, 5 Apr 2026 08:27:36 +0000 (+0200) Subject: fix: use articles section to properly detect and display articles X-Git-Url: https://git.danix.xyz/?a=commitdiff_plain;h=126d0f839fd66bd0b0d7c56931dc2a6f2f6886d3;p=danix2-hugo-theme.git fix: use articles section to properly detect and display articles Changed home.html to fetch articles from the /articles section directly instead of filtering by Type. This properly handles existing articles that may use different type field formats. Also increased articles shown from 3 to 6, sorted by date descending (newest first). Supports both old articles with custom 'type' fields and new articles with the tech/life/quote/link/photo system. Co-Authored-By: Claude Haiku 4.5 --- diff --git a/layouts/home.html b/layouts/home.html index 4d8587a..cffb6bc 100644 --- a/layouts/home.html +++ b/layouts/home.html @@ -5,9 +5,14 @@
Latest
- {{ range site.RegularPages }} - {{ if eq .Type "articles" }} - {{ $data := dict "title" .Title "type" .Params.type "description" .Summary "date" .Date "url" .RelPermalink "image" .Params.image "featured" .Params.featured }} + {{ $articlesSection := .Site.GetPage "/articles" }} + {{ if $articlesSection }} + {{ $articles := $articlesSection.Pages }} + {{ $articles := sort $articles "Date" "desc" }} + {{ range first 6 $articles }} + {{ $type := .Params.type }} + {{ if not $type }}{{ $type = "article" }}{{ end }} + {{ $data := dict "title" .Title "type" $type "description" .Summary "date" .Date "url" .RelPermalink "image" .Params.image "featured" .Params.featured }} {{ partial "post-card.html" $data }} {{ end }} {{ end }}