summaryrefslogtreecommitdiff
path: root/layouts/library
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-03-27 14:26:26 +0800
committerEltrac <hi@guhub.cn>2025-03-27 14:26:26 +0800
commit4802a50ca8ac768171f5e893dedadf81a215a95d (patch)
tree320308cacd562cd2fdbbbde6e79cff2e722f8473 /layouts/library
parent23c4ea229d931ec8a05192124de5de8996d6936d (diff)
feat: group library books by year
Former-commit-id: 7c4120af196f04e320a62c6102ef1e621c4a0538
Diffstat (limited to 'layouts/library')
-rw-r--r--layouts/library/section.html21
1 files changed, 14 insertions, 7 deletions
diff --git a/layouts/library/section.html b/layouts/library/section.html
index bc55b500..7d824879 100644
--- a/layouts/library/section.html
+++ b/layouts/library/section.html
@@ -2,13 +2,20 @@
{{ partial "header.html" . }}
<article id="library">
<div id="library-content">
- {{- range .Pages }}
- <div class="book{{ if eq .Params.rating 1 }} badbook{{ end }}{{ if eq .Params.rating 5 }} goodbook{{ end }}">
- <a href="{{ .Permalink }}" class="book-cover" style="view-transition-name: book-{{ .Title }}">
- <img src="{{ .Params.cover }}" />
- </a>
- </div>
- {{- end }}
+ {{ range .Pages.GroupByDate "2006" }} <!-- 按年份分组 -->
+ <h2>{{ .Key }}</h2> <!-- 显示年份 -->
+ <div class="book-group">
+ {{ range .Pages }}
+ <div class="book{{ if eq .Params.rating 1 }} badbook{{ end }}{{ if eq .Params.rating 5 }} goodbook{{ end }}">
+ <a href="{{ .Permalink }}" class="book-cover" style="view-transition-name: book-{{ .Title }}">
+ <img src="{{ .Params.cover }}!thumbnail"
+ class="lazy" data-src="{{ .Params.cover }}" />
+ </a>
+ </div>
+ {{ end }}
+ </div>
+ {{ end }}
+ <p>关于 2024 年的更多书目,请阅读《<a href="/posts/in-libris-libertas/#%E4%BB%8A%E5%B9%B4%E7%9A%84%E4%B9%A6%E5%8D%95">IN LIBRIS LIBERTAS</a>》</p>
</div>
</article>
{{ end }}