diff --git a/src/components/PostMeta.astro b/src/components/PostMeta.astro index b915d035..85fc51a3 100644 --- a/src/components/PostMeta.astro +++ b/src/components/PostMeta.astro @@ -53,7 +53,7 @@ const className = Astro.props.class;
- {category || i18n(I18nKey.uncategorized)} diff --git a/src/pages/archive/category/[category].astro b/src/pages/archive/category/[category].astro index 9e6a50f4..8972a5dc 100644 --- a/src/pages/archive/category/[category].astro +++ b/src/pages/archive/category/[category].astro @@ -10,13 +10,13 @@ export async function getStaticPaths() { return categories.map((category) => { return { params: { - category: category.name, + category: encodeURIComponent(category.name), }, }; }); } -const category = Astro.params.category as string; +const category = decodeURIComponent(Astro.params.category as string); --- diff --git a/src/utils/url-utils.ts b/src/utils/url-utils.ts index 4a6121ca..c52060c8 100644 --- a/src/utils/url-utils.ts +++ b/src/utils/url-utils.ts @@ -19,7 +19,7 @@ export function getPostUrlBySlug(slug: string): string { export function getCategoryUrl(category: string): string { if (category === i18n(i18nKey.uncategorized)) return url("/archive/category/uncategorized/"); - return url(`/archive/category/${category}/`); + return url(`/archive/category/${encodeURIComponent(category)}/`); } export function getDir(path: string): string {