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";
+30 -18
View File
@@ -12,33 +12,45 @@
Archives Archives
</h1> </h1>
</header> </header>
<div> <div class="archives">
<th:block th:each="archive : ${archives.items}"> <th:block
<h2 th:text="${archive.year}"></h2> th:each="archive, iter : ${theme.config.archives_page.pagination ? archives.items : postFinder.archives(1, archives.total).items}">
<ul> <details th:with="collapsibleMode=${theme.config.archives_page.collapsible}"
<th:block th:each="month : ${archive.months}"> th:open="${collapsibleMode == 'open' or (collapsibleMode == 'first' and iter.first)}">
<li class="post-list" th:each="post : ${month.posts}"> <summary>
<div class="post-meta"> <h2 th:text="${archive.year}"></h2>
<time class="post-time" </summary>
th:text="${#dates.format(post.spec.publishTime, '__${theme.config.style.time_style == 'custom' ? <ul>
<th:block th:each="month : ${archive.months}">
<li class="post-list" th:each="post : ${month.posts}">
<div class="post-meta">
<time class="post-time"
th:text="${#dates.format(post.spec.publishTime, '__${theme.config.style.time_style == 'custom' ?
theme.config.style.custom_time_style : theme.config.style.time_style}__')}"> theme.config.style.custom_time_style : theme.config.style.time_style}__')}">
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>
</li> </a>
</th:block> <th:block
</ul> th:replace="~{modules/tag-list(post = ${post}, show = ${theme.config.archives_page.show_tags})}"/>
</div>
</li>
</th:block>
</ul>
</details>
</th:block> </th:block>
</div> </div>
</article> </article>
<th:block th:replace="~{modules/pagination :: page( <th:block th:if="${theme.config.archives_page.pagination}">
<th:block th:replace="~{modules/pagination :: page(
hasPrevious=${archives.hasPrevious()}, hasPrevious=${archives.hasPrevious()},
previousUrl=@{${archives.prevUrl}}, previousUrl=@{${archives.prevUrl}},
hasNext=${archives.hasNext()}, hasNext=${archives.hasNext()},
nextUrl=@{${archives.nextUrl}}, nextUrl=@{${archives.nextUrl}},
previousClass='' previousClass=''
)}"/> )}"/>
</th:block>
</th:block> </th:block>
</html> </html>