mirror of
https://github.com/saicaca/fuwari.git
synced 2026-01-11 14:52:52 +01:00
Fix category with reserved character (#431)
Some checks failed
Code quality / quality (push) Failing after 3s
Build and Check / Astro Check for Node.js 22 (push) Failing after 4s
Build and Check / Astro Check for Node.js 23 (push) Failing after 5s
Build and Check / Astro Build for Node.js 22 (push) Failing after 4s
Build and Check / Astro Build for Node.js 23 (push) Failing after 4s
Some checks failed
Code quality / quality (push) Failing after 3s
Build and Check / Astro Check for Node.js 22 (push) Failing after 4s
Build and Check / Astro Check for Node.js 23 (push) Failing after 5s
Build and Check / Astro Build for Node.js 22 (push) Failing after 4s
Build and Check / Astro Build for Node.js 23 (push) Failing after 4s
* fix: Encode category in URLs to handle reserved characters * fix: Encode category names in static paths to handle reserved characters
This commit is contained in:
committed by
GitHub
parent
3194dfc521
commit
11535a9709
@@ -53,7 +53,7 @@ const className = Astro.props.class;
|
|||||||
<Icon name="material-symbols:book-2-outline-rounded" class="text-xl"></Icon>
|
<Icon name="material-symbols:book-2-outline-rounded" class="text-xl"></Icon>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row flex-nowrap items-center">
|
<div class="flex flex-row flex-nowrap items-center">
|
||||||
<a href={url(`/archive/category/${category || 'uncategorized'}/`)} aria-label=`View all posts in the ${category} category`
|
<a href={url(`/archive/category/${encodeURIComponent(category || 'uncategorized')}/`)} aria-label=`View all posts in the ${category} category`
|
||||||
class="link-lg transition text-50 text-sm font-medium
|
class="link-lg transition text-50 text-sm font-medium
|
||||||
hover:text-[var(--primary)] dark:hover:text-[var(--primary)] whitespace-nowrap">
|
hover:text-[var(--primary)] dark:hover:text-[var(--primary)] whitespace-nowrap">
|
||||||
{category || i18n(I18nKey.uncategorized)}
|
{category || i18n(I18nKey.uncategorized)}
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ export async function getStaticPaths() {
|
|||||||
return categories.map((category) => {
|
return categories.map((category) => {
|
||||||
return {
|
return {
|
||||||
params: {
|
params: {
|
||||||
category: category.name,
|
category: encodeURIComponent(category.name),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const category = Astro.params.category as string;
|
const category = decodeURIComponent(Astro.params.category as string);
|
||||||
---
|
---
|
||||||
|
|
||||||
<MainGridLayout title={i18n(I18nKey.archive)} description={i18n(I18nKey.archive)}>
|
<MainGridLayout title={i18n(I18nKey.archive)} description={i18n(I18nKey.archive)}>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export function getPostUrlBySlug(slug: string): string {
|
|||||||
export function getCategoryUrl(category: string): string {
|
export function getCategoryUrl(category: string): string {
|
||||||
if (category === i18n(i18nKey.uncategorized))
|
if (category === i18n(i18nKey.uncategorized))
|
||||||
return url("/archive/category/uncategorized/");
|
return url("/archive/category/uncategorized/");
|
||||||
return url(`/archive/category/${category}/`);
|
return url(`/archive/category/${encodeURIComponent(category)}/`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDir(path: string): string {
|
export function getDir(path: string): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user