Fix inaccessible /categories and /tags routes (#251)

Signed-off-by: Ryan Wang <i@ryanc.cc>
This commit is contained in:
Ryan Wang
2025-08-06 18:27:29 +08:00
committed by GitHub
parent 3701d3f943
commit bd11cc6c0d
6 changed files with 83 additions and 39 deletions

View File

@@ -24,8 +24,11 @@ page.moments.title=Moments
page.photos.title=Photos
page.tags.title=Tags
page.tags.morePosts=More Posts
page.tags.empty=No Tags
page.tag.title=Tag: {0}
page.categories.title=Categories
page.categories.morePosts=More Posts
page.categories.empty=No Categories
page.category.title=Category: {0}
page.author.title=Author: {0}
page.error.backToHome=Back to Home

View File

@@ -24,8 +24,11 @@ page.moments.title=Momentos
page.photos.title=Galería
page.tags.title=Etiquetas
page.tags.morePosts=Más Publicaciones
page.tags.empty=No hay Etiquetas
page.tag.title=Etiqueta: {0}
page.categories.title=Categorías
page.categories.morePosts=Más Publicaciones
page.categories.empty=No hay Categorías
page.category.title=Categoría: {0}
page.author.title=Autor: {0}
page.error.backToHome=Volver al Inicio

View File

@@ -24,8 +24,11 @@ page.moments.title=瞬间
page.photos.title=图库
page.tags.title=标签
page.tags.morePosts=更多文章
page.tags.empty=暂无标签
page.tag.title=标签:{0}
page.categories.title=分类
page.categories.morePosts=更多文章
page.categories.empty=暂无分类
page.category.title=分类:{0}
page.author.title=作者:{0}
page.error.backToHome=返回首页

View File

@@ -24,8 +24,11 @@ page.moments.title=瞬間
page.photos.title=圖庫
page.tags.title=標籤
page.tags.morePosts=更多文章
page.tags.empty=暫無標籤
page.tag.title=標籤:{0}
page.categories.title=分類
page.categories.morePosts=更多文章
page.categories.empty=暫無分類
page.category.title=分類:{0}
page.author.title=作者:{0}
page.error.backToHome=返回首頁

View File

@@ -7,28 +7,44 @@
<th:block th:replace="~{modules/category-filter}" />
<th:block th:with="categories = ${categoryFinder.listAsTree()}">
<th:block
th:with="posts = ${postFinder.listByCategory(1,10,categories[0].metadata.name)},list_layout=${theme.config.layout.post_list_layout}"
>
<div
id="post-list"
th:if="${posts.total gt 0}"
class="mt-6 grid grid-cols-1 gap-6"
th:classappend="|${list_layout == 'grid_3' ? 'md:grid-cols-2 xl:grid-cols-3' : ''} ${list_layout == 'grid_2' ? 'md:grid-cols-2' : ''}|"
>
<th:block th:each="post : ${posts.items}">
<th:block
th:replace="~{modules/post-card :: post-card(${post},true,true,true,${list_layout == 'single' ? 'column' : 'row'})}"
/>
</th:block>
<th:block th:if="${#lists.isEmpty(categories)}">
<div class="mt-6 flex items-center justify-center">
<span class="text-sm font-light text-gray-600" th:text="#{page.categories.empty}"></span>
</div>
</th:block>
<div th:if="${posts.total == 0}" class="mt-6 flex items-center justify-center">
<span class="text-sm font-light text-gray-600" th:text="#{common.noPosts}"></span>
</div>
<th:block th:unless="${#lists.isEmpty(categories)}" th:with="category = ${categories[0]}">
<th:block
th:replace="~{modules/pagination :: pagination(context = |${categories[0].status.permalink}/|, prevUrl = ${posts.prevUrl}, nextUrl = ${posts.nextUrl}, totalPages = ${posts.totalPages}, page = ${posts.page}, hasPrevious = ${posts.hasPrevious()}, hasNext = ${posts.hasNext()})}"
/>
th:with="posts = ${postFinder.listByCategory(1,10,category.metadata.name)},list_layout=${theme.config.layout.post_list_layout}"
>
<div
id="post-list"
th:if="${posts.total gt 0}"
class="mt-6 grid grid-cols-1 gap-6"
th:classappend="|${list_layout == 'grid_3' ? 'md:grid-cols-2 xl:grid-cols-3' : ''} ${list_layout == 'grid_2' ? 'md:grid-cols-2' : ''}|"
>
<th:block th:each="post : ${posts.items}">
<th:block
th:replace="~{modules/post-card :: post-card(${post},true,true,true,${list_layout == 'single' ? 'column' : 'row'})}"
/>
</th:block>
</div>
<div th:if="${posts.total == 0}" class="mt-6 flex items-center justify-center">
<span class="text-sm font-light text-gray-600" th:text="#{common.noPosts}"></span>
</div>
<div th:if="${posts.total gt 10}" class="mt-10 flex justify-end">
<a
class="group inline-flex items-center gap-2 truncate text-sm text-gray-600 hover:text-gray-900 dark:text-slate-100 dark:hover:text-slate-200"
th:href="@{${category.status.permalink}}"
>
<span th:text="#{page.categories.morePosts}"></span>
<span
class="i-tabler-chevron-right -translate-x-1 text-lg transition-all group-hover:translate-x-0"
></span>
</a>
</div>
</th:block>
</th:block>
</th:block>
</th:block>

View File

@@ -8,29 +8,45 @@
<th:block th:replace="~{modules/tag-filter}" />
</div>
<th:block th:with="tag = ${tagFinder.list(1,1).items[0]}">
<th:block th:if="${tag}" th:with="posts = ${postFinder.listByTag(1,10,tag.metadata.name)}">
<div
id="post-list"
th:if="${posts.total gt 0}"
th:with="postItems=${posts.items},list_layout=${theme.config.layout.post_list_layout}"
class="mt-6 grid grid-cols-1 gap-6"
th:classappend="|${list_layout == 'grid_3' ? 'md:grid-cols-2 xl:grid-cols-3' : ''} ${list_layout == 'grid_2' ? 'md:grid-cols-2' : ''}|"
>
<th:block th:each="post : ${postItems}">
<th:block
th:replace="~{modules/post-card :: post-card(${post},true,true,true,${list_layout == 'single' ? 'column' : 'row'})}"
/>
</th:block>
<th:block th:with="tags = ${tagFinder.listAll()}">
<th:block th:if="${#lists.isEmpty(tags)}">
<div class="mt-6 flex items-center justify-center">
<span class="text-sm font-light text-gray-600" th:text="#{page.tags.empty}"></span>
</div>
</th:block>
<div th:if="${posts.total == 0}" class="mt-6 flex items-center justify-center">
<span class="text-sm font-light text-gray-600 dark:text-slate-200" th:text="#{common.noPosts}"></span>
</div>
<th:block th:unless="${#lists.isEmpty(tags)}" th:with="tag = ${tags[0]}">
<th:block th:with="posts = ${postFinder.listByTag(1,10,tag.metadata.name)}">
<div
id="post-list"
th:if="${posts.total gt 0}"
th:with="postItems=${posts.items},list_layout=${theme.config.layout.post_list_layout}"
class="mt-6 grid grid-cols-1 gap-6"
th:classappend="|${list_layout == 'grid_3' ? 'md:grid-cols-2 xl:grid-cols-3' : ''} ${list_layout == 'grid_2' ? 'md:grid-cols-2' : ''}|"
>
<th:block th:each="post : ${postItems}">
<th:block
th:replace="~{modules/post-card :: post-card(${post},true,true,true,${list_layout == 'single' ? 'column' : 'row'})}"
/>
</th:block>
</div>
<th:block
th:replace="~{modules/pagination :: pagination(context = |${tag.status.permalink}/|, prevUrl = ${posts.prevUrl}, nextUrl = ${posts.nextUrl}, totalPages = ${posts.totalPages}, page = ${posts.page}, hasPrevious = ${posts.hasPrevious()}, hasNext = ${posts.hasNext()})}"
/>
<div th:if="${posts.total == 0}" class="mt-6 flex items-center justify-center">
<span class="text-sm font-light text-gray-600 dark:text-slate-200" th:text="#{common.noPosts}"></span>
</div>
<div th:if="${posts.total gt 10}" class="mt-10 flex justify-end">
<a
class="group inline-flex items-center gap-2 truncate text-sm text-gray-600 hover:text-gray-900 dark:text-slate-100 dark:hover:text-slate-200"
th:href="@{${tag.status.permalink}}"
>
<span th:text="#{page.tags.morePosts}"></span>
<span
class="i-tabler-chevron-right -translate-x-1 text-lg transition-all group-hover:translate-x-0"
></span>
</a>
</div>
</th:block>
</th:block>
</th:block>
</th:block>