feat: add configurable archive display modes

This commit is contained in:
Erzbir
2026-08-14 01:35:58 +08:00
parent ff8d2377e3
commit dbd4e05424
4 changed files with 55 additions and 18 deletions
+15
View File
@@ -402,6 +402,21 @@ spec:
name: show_tags
label: 显示文章标签
value: false
- $formkit: checkbox
name: pagination
label: 是否分页
value: true
- $formkit: select
name: collapsible
label: 展开模式
value: "open"
options:
- label: "只展开第一项"
value: "first"
- label: "全部展开"
value: "open"
- label: "全部收起"
value: "close"
- group: categories_page
label: 分类页
+9
View File
@@ -0,0 +1,9 @@
.archives {
details {
> summary {
> h2 {
display: inline-block;
}
}
}
}
+1
View File
@@ -18,3 +18,4 @@
@use "typed-text";
@use "friends";
@use "contact";
@use "archives";
+16 -4
View File
@@ -12,9 +12,14 @@
Archives
</h1>
</header>
<div>
<th:block th:each="archive : ${archives.items}">
<div class="archives">
<th:block
th:each="archive, iter : ${theme.config.archives_page.pagination ? archives.items : postFinder.archives(1, archives.total).items}">
<details th:with="collapsibleMode=${theme.config.archives_page.collapsible}"
th:open="${collapsibleMode == 'open' or (collapsibleMode == 'first' and iter.first)}">
<summary>
<h2 th:text="${archive.year}"></h2>
</summary>
<ul>
<th:block th:each="month : ${archive.months}">
<li class="post-list" th:each="post : ${month.posts}">
@@ -25,14 +30,20 @@
Publish
Time
</time>
<a data-pjax th:href="@{${post.status.permalink}}"><span class="post-list-title" th:text="${post.spec.title}">Post Title</span>
</a><th:block th:replace="~{modules/tag-list(post = ${post}, show = ${theme.config.archives_page.show_tags})}"/></div>
<a data-pjax th:href="@{${post.status.permalink}}"><span class="post-list-title"
th:text="${post.spec.title}">Post Title</span>
</a>
<th:block
th:replace="~{modules/tag-list(post = ${post}, show = ${theme.config.archives_page.show_tags})}"/>
</div>
</li>
</th:block>
</ul>
</details>
</th:block>
</div>
</article>
<th:block th:if="${theme.config.archives_page.pagination}">
<th:block th:replace="~{modules/pagination :: page(
hasPrevious=${archives.hasPrevious()},
previousUrl=@{${archives.prevUrl}},
@@ -40,5 +51,6 @@
nextUrl=@{${archives.nextUrl}},
previousClass=''
)}"/>
</th:block>
</th:block>
</html>