summaryrefslogtreecommitdiff
path: root/layouts/library/section.html
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-11-06 10:43:16 +0800
committerEltrac <hi@guhub.cn>2025-11-06 10:43:16 +0800
commit1fafbca42b787fa00767f7170666c24dd768a6da (patch)
tree75602fbbc9ab5500ebe271c81969b727c1066d2e /layouts/library/section.html
parent2e139bd00a21f66d93d473e4b1aa007af6e24694 (diff)
feat: unify section titles
Former-commit-id: d5a29ffa1c93b3fded194400e62f118fb06c5df7
Diffstat (limited to 'layouts/library/section.html')
-rw-r--r--layouts/library/section.html23
1 files changed, 15 insertions, 8 deletions
diff --git a/layouts/library/section.html b/layouts/library/section.html
index cd95b8e8..973c6351 100644
--- a/layouts/library/section.html
+++ b/layouts/library/section.html
@@ -2,16 +2,20 @@
<article class="pagefind-exclude">
{{ partial "header.html" . }}
<div>
- <h2>{{ now.Year }} 年读的书</h2>
+ {{ $booksThisYear := where (where .Site.RegularPages "Section" "library") "Date.Year" now.Year }}
+
+ {{ partial "components/section-title" (dict
+ "Left" now.Year
+ "Right" (printf "共 %d 篇书评" (len $booksThisYear))
+ )}}
+
<div class="grid grid-cols-4 md:grid-cols-6 items-center gap-4 my-4">
- {{ $books := first 18 (where .Site.RegularPages "Section" "library") }}
- {{ range $i, $book := $books }}
- {{ if eq .Date.Year now.Year }}
+ {{ $first18BooksThisYear := first 18 $booksThisYear }}
+ {{ range $i, $book := $first18BooksThisYear }}
<div class="{{ if gt $i 15 }}hidden md:block{{ end }}"
data-tooltip="{{ $book.Title }}">
{{ partial "items/book" $book }}
</div>
- {{ end }}
{{ end }}
</div>
@@ -23,7 +27,6 @@
{{ end }}
{{ end }}
-
<div class="flex items-center my-8">
<a href="/library/2025" class="small-button">
{{ T "library.viewAllThisYear" }}
@@ -37,9 +40,13 @@
</p>
</div>
- <h2>推荐好书</h2>
+ {{ $goodBooks := where (where .Site.RegularPages "Section" "library") ".Params.rating" "==" 5 }}
+ {{ partial "components/section-title" (dict
+ "Left" "推荐好书"
+ "Right" (printf "共 %d 本" (len $goodBooks))
+ )}}
<div class="grid grid-cols-4 md:grid-cols-6 items-center gap-4 my-4">
- {{ range where (where .Site.RegularPages "Section" "library") ".Params.rating" "==" 5 }}
+ {{ range $goodBooks }}
<div data-tooltip="{{ .Title }}">{{ partial "items/book" . }}</div>
{{ end }}
</div>