diff options
| author | BigCoke233 <hi@guhub.cn> | 2026-01-08 11:09:48 +0800 |
|---|---|---|
| committer | BigCoke233 <hi@guhub.cn> | 2026-01-08 11:09:48 +0800 |
| commit | 57a5a0ccd50b09eb35befadf098cb23bdd95f780 (patch) | |
| tree | a3bad42a0f5641130c97a799ea2d19f72d4a5279 /layouts/library | |
| parent | 7ecccf4ca2a06b7ca28828ef066b2809c7260815 (diff) | |
fix: books out of order
and better year list layout
Diffstat (limited to 'layouts/library')
| -rw-r--r-- | layouts/library/section.html | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/layouts/library/section.html b/layouts/library/section.html index 7d4ad330..ce2e6ff6 100644 --- a/layouts/library/section.html +++ b/layouts/library/section.html @@ -3,7 +3,8 @@ {{ $isLibraryHome := eq .RelPermalink "/library/" }} {{ $books := .RegularPages }} {{ if $isLibraryHome }} - {{ range .Sections }} + {{ $sections := .Sections | collections.Reverse}} + {{ range $sections }} {{ $books = $books | append .RegularPages }} {{ end }} {{ end }} @@ -12,6 +13,8 @@ {{ range .Sections }} {{ $years = $years | append .Title }} {{ end }} +{{ $years = $years | collections.Reverse }} + <article class="pagefind-exclude"> {{ partial "header.html" . }} {{ partial "home/home-nav" . }} @@ -46,15 +49,18 @@ {{ if $isLibraryHome }} <!-- === year list === --> - <div class="flex items-center my-8"> - <a href="/library/2025" class="small-button"> + <div class="flex items-center my-8 justify-between gap-4"> + <a href="/library/{{ now.Year }}" class="small-button"> {{ T "library.viewAllThisYear" }} <span class="text-secondary">→</span> </a> - <p class="my-0 mx-4"> + <p class="my-0"> {{ $currentYear := printf "%d" now.Year }} - {{ range $years }} - {{ if ne . $currentYear }}<a class="text-secondary" href="{{ printf "/library/%s/" . }}">{{ . }} 年</a>{{ end }} + {{ range $i, $year := $years }} + {{ if ne $year $currentYear }} + <a class="text-secondary" href="{{ printf "/library/%s/" $year }}">{{ $year }} 年</a> + {{ if not (eq $i (sub (len $years) 1)) }}·{{ end }} + {{ end }} {{ end }} </p> </div> |
