diff options
| author | Danilo M. <danix@danix.xyz> | 2026-04-21 11:36:52 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-04-21 11:36:52 +0200 |
| commit | 46ce86242815f5051c15fefda733853ca59ef1a3 (patch) | |
| tree | e09417d36bdb8bc9ea6c0f65c02cc6e3b89f0d9b | |
| parent | 321252d606511ddd9e8e365e39109057b0d22027 (diff) | |
| download | danixxyz-46ce86242815f5051c15fefda733853ca59ef1a3.tar.gz danixxyz-46ce86242815f5051c15fefda733853ca59ef1a3.zip | |
feat: use timeline container in default list template
| -rw-r--r-- | themes/danix-xyz-hacker/layouts/_default/list.html | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/themes/danix-xyz-hacker/layouts/_default/list.html b/themes/danix-xyz-hacker/layouts/_default/list.html index 7d8c263..09c0cbb 100644 --- a/themes/danix-xyz-hacker/layouts/_default/list.html +++ b/themes/danix-xyz-hacker/layouts/_default/list.html @@ -1,39 +1,39 @@ {{ define "main" }} -<div class="mx-auto px-4 py-12 max-w-4xl"> - <!-- Page title --> +<div class="mx-auto px-4 py-12 max-w-5xl"> <h1 class="text-4xl md:text-5xl font-bold text-accent mb-12"> {{ .Title }} </h1> - <!-- Articles list --> - <div class="space-y-6 max-w-3xl"> - {{ $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 --> + {{ $pinned := where .Pages "Params.pinned" true }} + {{ $unpinned := where .Pages "Params.pinned" false }} + {{ if eq (len $unpinned) 0 }} + {{ $unpinned = where .Pages "Params.pinned" nil }} {{ if eq (len $unpinned) 0 }} - {{ $unpinned = where .Pages "Params.pinned" nil }} - {{ if eq (len $unpinned) 0 }} - {{ $unpinned = where .Pages "Params.pinned" "" }} - {{ end }} + {{ $unpinned = where .Pages "Params.pinned" "" }} {{ end }} + {{ end }} - <!-- Pinned posts first --> - {{ range (sort $pinned "Date" "desc") }} - {{ partial "article-list-item.html" . }} - {{ end }} + {{ $allPages := ($pinned | append $unpinned) }} - <!-- Regular posts --> - {{ range (sort $unpinned "Date" "desc") }} - {{ partial "article-list-item.html" . }} + {{ if eq (len $allPages) 0 }} + <div class="py-12 text-center text-text-dim"> + {{ i18n "noRelated" }} + </div> + {{ else }} + <ol class="timeline" aria-label="{{ .Title }}"> + {{ range $i, $page := (sort $pinned "Date" "desc") }} + {{ $side := "left" }} + {{ if eq (mod $i 2) 0 }}{{ $side = "left" }}{{ else }}{{ $side = "right" }}{{ end }} + {{ partial "article-list-item.html" (dict "Page" $page "side" $side) }} {{ end }} - - <!-- Empty state --> - {{ if eq (len .Pages) 0 }} - <div class="py-12 text-center text-text-dim"> - {{ i18n "noRelated" }} - </div> + {{ $offset := len $pinned }} + {{ range $i, $page := (sort $unpinned "Date" "desc") }} + {{ $idx := add $i $offset }} + {{ $side := "left" }} + {{ if eq (mod $idx 2) 0 }}{{ $side = "left" }}{{ else }}{{ $side = "right" }}{{ end }} + {{ partial "article-list-item.html" (dict "Page" $page "side" $side) }} {{ end }} - </div> + </ol> + {{ end }} </div> {{ end }} |
