Skip to content

Commit bd11cc6

Browse files
authored
Fix inaccessible /categories and /tags routes (#251)
Signed-off-by: Ryan Wang <[email protected]>
1 parent 3701d3f commit bd11cc6

File tree

6 files changed

+83
-39
lines changed

6 files changed

+83
-39
lines changed

i18n/default.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ page.moments.title=Moments
2424
page.photos.title=Photos
2525
page.tags.title=Tags
2626
page.tags.morePosts=More Posts
27+
page.tags.empty=No Tags
2728
page.tag.title=Tag: {0}
2829
page.categories.title=Categories
30+
page.categories.morePosts=More Posts
31+
page.categories.empty=No Categories
2932
page.category.title=Category: {0}
3033
page.author.title=Author: {0}
3134
page.error.backToHome=Back to Home

i18n/es.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ page.moments.title=Momentos
2424
page.photos.title=Galería
2525
page.tags.title=Etiquetas
2626
page.tags.morePosts=Más Publicaciones
27+
page.tags.empty=No hay Etiquetas
2728
page.tag.title=Etiqueta: {0}
2829
page.categories.title=Categorías
30+
page.categories.morePosts=Más Publicaciones
31+
page.categories.empty=No hay Categorías
2932
page.category.title=Categoría: {0}
3033
page.author.title=Autor: {0}
3134
page.error.backToHome=Volver al Inicio

i18n/zh_CN.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ page.moments.title=瞬间
2424
page.photos.title=图库
2525
page.tags.title=标签
2626
page.tags.morePosts=更多文章
27+
page.tags.empty=暂无标签
2728
page.tag.title=标签:{0}
2829
page.categories.title=分类
30+
page.categories.morePosts=更多文章
31+
page.categories.empty=暂无分类
2932
page.category.title=分类:{0}
3033
page.author.title=作者:{0}
3134
page.error.backToHome=返回首页

i18n/zh_TW.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ page.moments.title=瞬間
2424
page.photos.title=圖庫
2525
page.tags.title=標籤
2626
page.tags.morePosts=更多文章
27+
page.tags.empty=暫無標籤
2728
page.tag.title=標籤:{0}
2829
page.categories.title=分類
30+
page.categories.morePosts=更多文章
31+
page.categories.empty=暫無分類
2932
page.category.title=分類:{0}
3033
page.author.title=作者:{0}
3134
page.error.backToHome=返回首頁

templates/categories.html

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,44 @@
77
<th:block th:replace="~{modules/category-filter}" />
88

99
<th:block th:with="categories = ${categoryFinder.listAsTree()}">
10-
<th:block
11-
th:with="posts = ${postFinder.listByCategory(1,10,categories[0].metadata.name)},list_layout=${theme.config.layout.post_list_layout}"
12-
>
13-
<div
14-
id="post-list"
15-
th:if="${posts.total gt 0}"
16-
class="mt-6 grid grid-cols-1 gap-6"
17-
th:classappend="|${list_layout == 'grid_3' ? 'md:grid-cols-2 xl:grid-cols-3' : ''} ${list_layout == 'grid_2' ? 'md:grid-cols-2' : ''}|"
18-
>
19-
<th:block th:each="post : ${posts.items}">
20-
<th:block
21-
th:replace="~{modules/post-card :: post-card(${post},true,true,true,${list_layout == 'single' ? 'column' : 'row'})}"
22-
/>
23-
</th:block>
10+
<th:block th:if="${#lists.isEmpty(categories)}">
11+
<div class="mt-6 flex items-center justify-center">
12+
<span class="text-sm font-light text-gray-600" th:text="#{page.categories.empty}"></span>
2413
</div>
14+
</th:block>
2515

26-
<div th:if="${posts.total == 0}" class="mt-6 flex items-center justify-center">
27-
<span class="text-sm font-light text-gray-600" th:text="#{common.noPosts}"></span>
28-
</div>
16+
<th:block th:unless="${#lists.isEmpty(categories)}" th:with="category = ${categories[0]}">
2917
<th:block
30-
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()})}"
31-
/>
18+
th:with="posts = ${postFinder.listByCategory(1,10,category.metadata.name)},list_layout=${theme.config.layout.post_list_layout}"
19+
>
20+
<div
21+
id="post-list"
22+
th:if="${posts.total gt 0}"
23+
class="mt-6 grid grid-cols-1 gap-6"
24+
th:classappend="|${list_layout == 'grid_3' ? 'md:grid-cols-2 xl:grid-cols-3' : ''} ${list_layout == 'grid_2' ? 'md:grid-cols-2' : ''}|"
25+
>
26+
<th:block th:each="post : ${posts.items}">
27+
<th:block
28+
th:replace="~{modules/post-card :: post-card(${post},true,true,true,${list_layout == 'single' ? 'column' : 'row'})}"
29+
/>
30+
</th:block>
31+
</div>
32+
33+
<div th:if="${posts.total == 0}" class="mt-6 flex items-center justify-center">
34+
<span class="text-sm font-light text-gray-600" th:text="#{common.noPosts}"></span>
35+
</div>
36+
<div th:if="${posts.total gt 10}" class="mt-10 flex justify-end">
37+
<a
38+
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"
39+
th:href="@{${category.status.permalink}}"
40+
>
41+
<span th:text="#{page.categories.morePosts}"></span>
42+
<span
43+
class="i-tabler-chevron-right -translate-x-1 text-lg transition-all group-hover:translate-x-0"
44+
></span>
45+
</a>
46+
</div>
47+
</th:block>
3248
</th:block>
3349
</th:block>
3450
</th:block>

templates/tags.html

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,45 @@
88
<th:block th:replace="~{modules/tag-filter}" />
99
</div>
1010

11-
<th:block th:with="tag = ${tagFinder.list(1,1).items[0]}">
12-
<th:block th:if="${tag}" th:with="posts = ${postFinder.listByTag(1,10,tag.metadata.name)}">
13-
<div
14-
id="post-list"
15-
th:if="${posts.total gt 0}"
16-
th:with="postItems=${posts.items},list_layout=${theme.config.layout.post_list_layout}"
17-
class="mt-6 grid grid-cols-1 gap-6"
18-
th:classappend="|${list_layout == 'grid_3' ? 'md:grid-cols-2 xl:grid-cols-3' : ''} ${list_layout == 'grid_2' ? 'md:grid-cols-2' : ''}|"
19-
>
20-
<th:block th:each="post : ${postItems}">
21-
<th:block
22-
th:replace="~{modules/post-card :: post-card(${post},true,true,true,${list_layout == 'single' ? 'column' : 'row'})}"
23-
/>
24-
</th:block>
11+
<th:block th:with="tags = ${tagFinder.listAll()}">
12+
<th:block th:if="${#lists.isEmpty(tags)}">
13+
<div class="mt-6 flex items-center justify-center">
14+
<span class="text-sm font-light text-gray-600" th:text="#{page.tags.empty}"></span>
2515
</div>
16+
</th:block>
2617

27-
<div th:if="${posts.total == 0}" class="mt-6 flex items-center justify-center">
28-
<span class="text-sm font-light text-gray-600 dark:text-slate-200" th:text="#{common.noPosts}"></span>
29-
</div>
18+
<th:block th:unless="${#lists.isEmpty(tags)}" th:with="tag = ${tags[0]}">
19+
<th:block th:with="posts = ${postFinder.listByTag(1,10,tag.metadata.name)}">
20+
<div
21+
id="post-list"
22+
th:if="${posts.total gt 0}"
23+
th:with="postItems=${posts.items},list_layout=${theme.config.layout.post_list_layout}"
24+
class="mt-6 grid grid-cols-1 gap-6"
25+
th:classappend="|${list_layout == 'grid_3' ? 'md:grid-cols-2 xl:grid-cols-3' : ''} ${list_layout == 'grid_2' ? 'md:grid-cols-2' : ''}|"
26+
>
27+
<th:block th:each="post : ${postItems}">
28+
<th:block
29+
th:replace="~{modules/post-card :: post-card(${post},true,true,true,${list_layout == 'single' ? 'column' : 'row'})}"
30+
/>
31+
</th:block>
32+
</div>
33+
34+
<div th:if="${posts.total == 0}" class="mt-6 flex items-center justify-center">
35+
<span class="text-sm font-light text-gray-600 dark:text-slate-200" th:text="#{common.noPosts}"></span>
36+
</div>
3037

31-
<th:block
32-
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()})}"
33-
/>
38+
<div th:if="${posts.total gt 10}" class="mt-10 flex justify-end">
39+
<a
40+
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"
41+
th:href="@{${tag.status.permalink}}"
42+
>
43+
<span th:text="#{page.tags.morePosts}"></span>
44+
<span
45+
class="i-tabler-chevron-right -translate-x-1 text-lg transition-all group-hover:translate-x-0"
46+
></span>
47+
</a>
48+
</div>
49+
</th:block>
3450
</th:block>
3551
</th:block>
3652
</th:block>

0 commit comments

Comments
 (0)