mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
feat: remove redundant /en
This commit is contained in:
1 parent
e4558d978c
commit
cb3e759f75
2 files changed
+15
-3
No files matched your search
@@ -46,9 +46,19 @@ const isRoot = pathname === '/';
|
|||||||
window.location.pathname.startsWith(`/${locale}`),
|
window.location.pathname.startsWith(`/${locale}`),
|
||||||
);
|
);
|
||||||
const bestLocale = getBestLocale();
|
const bestLocale = getBestLocale();
|
||||||
|
const currentPathLocale = SUPPORTED_LOCALES.find((locale) =>
|
||||||
|
window.location.pathname.startsWith(`/${locale}`),
|
||||||
|
);
|
||||||
|
|
||||||
if (!isI18nPath && bestLocale !== undefined) {
|
console.log(bestLocale);
|
||||||
window.location.pathname = `/${bestLocale}${window.location.pathname}`;
|
|
||||||
|
if (bestLocale !== currentPathLocale) {
|
||||||
|
window.location.pathname = isI18nPath
|
||||||
|
? window.location.pathname.replace(
|
||||||
|
`/${currentPathLocale}`,
|
||||||
|
bestLocale === undefined ? '' : `/${bestLocale}`,
|
||||||
|
)
|
||||||
|
: `/${bestLocale}${window.location.pathname}`;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -33,7 +33,9 @@ const strings = getStrings(Astro.params.locale);
|
|||||||
|
|
||||||
export const getStaticPaths = (() => {
|
export const getStaticPaths = (() => {
|
||||||
return [
|
return [
|
||||||
...SUPPORTED_LOCALES.map((locale) => ({ params: { locale } })),
|
...SUPPORTED_LOCALES.filter((locale) => locale !== DEFAULT_LOCALE).map(
|
||||||
|
(locale) => ({ params: { locale } }),
|
||||||
|
),
|
||||||
{ params: { locale: undefined } },
|
{ params: { locale: undefined } },
|
||||||
];
|
];
|
||||||
}) satisfies GetStaticPaths;
|
}) satisfies GetStaticPaths;
|
||||||
|
|||||||
Reference in new issue
Block a user