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 name: show_tags
label: 显示文章标签 label: 显示文章标签
value: false 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 - group: categories_page
label: 分类页 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 "typed-text";
@use "friends"; @use "friends";
@use "contact"; @use "contact";
@use "archives";
+16 -4
View File
@@ -12,9 +12,14 @@
Archives Archives
</h1> </h1>
</header> </header>
<div> <div class="archives">
<th:block th:each="archive : ${archives.items}"> <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> <h2 th:text="${archive.year}"></h2>
</summary>
<ul> <ul>
<th:block th:each="month : ${archive.months}"> <th:block th:each="month : ${archive.months}">
<li class="post-list" th:each="post : ${month.posts}"> <li class="post-list" th:each="post : ${month.posts}">
@@ -25,14 +30,20 @@
Publish Publish
Time Time
</time> </time>
<a data-pjax th:href="@{${post.status.permalink}}"><span class="post-list-title" th:text="${post.spec.title}">Post Title</span> <a data-pjax th:href="@{${post.status.permalink}}"><span class="post-list-title"
</a><th:block th:replace="~{modules/tag-list(post = ${post}, show = ${theme.config.archives_page.show_tags})}"/></div> 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> </li>
</th:block> </th:block>
</ul> </ul>
</details>
</th:block> </th:block>
</div> </div>
</article> </article>
<th:block th:if="${theme.config.archives_page.pagination}">
<th:block th:replace="~{modules/pagination :: page( <th:block th:replace="~{modules/pagination :: page(
hasPrevious=${archives.hasPrevious()}, hasPrevious=${archives.hasPrevious()},
previousUrl=@{${archives.prevUrl}}, previousUrl=@{${archives.prevUrl}},
@@ -40,5 +51,6 @@
nextUrl=@{${archives.nextUrl}}, nextUrl=@{${archives.nextUrl}},
previousClass='' previousClass=''
)}"/> )}"/>
</th:block>
</th:block> </th:block>
</html> </html>