]> danix's work - danix2-hugo-theme.git/commitdiff
fix: use articles section to properly detect and display articles
authorDanilo M. <redacted>
Sun, 5 Apr 2026 08:27:36 +0000 (10:27 +0200)
committerDanilo M. <redacted>
Sun, 5 Apr 2026 08:27:36 +0000 (10:27 +0200)
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 <redacted>
layouts/home.html

index 4d8587a8763f6c35a971a5ea7aba7cd8df97d2c1..cffb6bc83d2d446540373195e14e3b4f46ae3640 100644 (file)
@@ -5,9 +5,14 @@
     <div class="feed-label">Latest</div>
 
     <div class="feed-grid">
-      {{ 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 }}