Skip to content

Commit 6437f81

Browse files
committed
feat: show category name
1 parent 6b5e32d commit 6437f81

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/pages/categories/[category].astro

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface Props {
1111
}
1212
1313
const category = Astro.params.category
14+
const categoryName = getCategoryName(category?.toString() ?? '')
1415
1516
export const getStaticPaths: GetStaticPaths = async () => {
1617
const posts = await getPosts()
@@ -25,7 +26,7 @@ export const getStaticPaths: GetStaticPaths = async () => {
2526
}
2627
---
2728

28-
<ContentLayout title={`分类 - ${getCategoryName(category?.toString() ?? '')}`}>
29-
<h1>分类 - {category}</h1>
29+
<ContentLayout title={`分类 - ${categoryName}`}>
30+
<h1>分类 - {categoryName}</h1>
3031
<PostList posts={Astro.props.posts} />
3132
</ContentLayout>

src/pages/posts/index.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import ContentLayout from '@/layouts/ContentLayout.astro'
33
import { getPosts, getTags, getCategories } from '@/utils/post'
44
import { Shapes, Tags } from 'lucide-react'
55
import PostList from '@/components/common/PostList.astro'
6+
import { getCategoryName } from '@/utils/names'
67
78
const posts = await getPosts()
89
const tags = getTags(posts)
@@ -32,7 +33,7 @@ const categories = getCategories(posts)
3233
categories.map(([category, count]) => (
3334
<span class="inline-block">
3435
<a href={`/categories/${category}`}>
35-
{category}
36+
{getCategoryName(category)}
3637
<span class="text-xs">{count}</span>
3738
</a>
3839
</span>

0 commit comments

Comments
 (0)