]> danix's work - danix.xyz-2.git/commitdiff
Fix article list template to display articles without pinned parameter
authorDanilo M. <redacted>
Wed, 15 Apr 2026 20:21:22 +0000 (22:21 +0200)
committerDanilo M. <redacted>
Wed, 15 Apr 2026 20:21:22 +0000 (22:21 +0200)
- Handle undefined .Params.pinned gracefully by checking for nil/"" values
- This allows articles without explicit pinned param to appear in regular posts section
- Added check: if where clause returns no unpinned posts, search for nil/empty params
- Articles test index now has proper TOML frontmatter with title

Co-Authored-By: Claude Haiku 4.5 <redacted>
content/en/articles/_index.md
themes/danix-xyz-hacker/layouts/_default/list.html

index 175716df67987587020c10de2ccdefb2aec229fc..0ac1782e67b4b436ad10fd4f53893c588fb08a22 100644 (file)
@@ -1 +1,5 @@
++++
+title = "Articles"
++++
+
 My articles
index 357b8565e0106e67f2a10ac8c5e0d4afc75ad0ed..7d8c26352f301aa19421f420c366015efe5a7753 100644 (file)
     {{ $pinned := where .Pages "Params.pinned" true }}
     {{ $unpinned := where .Pages "Params.pinned" false }}
 
+    <!-- If no unpinned posts found (because param is undefined), get all non-pinned pages -->
+    {{ if eq (len $unpinned) 0 }}
+      {{ $unpinned = where .Pages "Params.pinned" nil }}
+      {{ if eq (len $unpinned) 0 }}
+        {{ $unpinned = where .Pages "Params.pinned" "" }}
+      {{ end }}
+    {{ end }}
+
     <!-- Pinned posts first -->
     {{ range (sort $pinned "Date" "desc") }}
       {{ partial "article-list-item.html" . }}