mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
fix: legacy redirector ensure props
This commit is contained in:
1 parent
9a3f64fcd6
commit
12e645f6e2
4 files changed
+9
-7
No files matched your search
Submodule
+1
Submodule packages/cue4parse added at b8c9dab500.
@@ -4,11 +4,11 @@
|
||||
|
||||
const isAPI = window.location.pathname.startsWith("/api");
|
||||
const isI18nPath = locales.supported.some(({ locale }) =>
|
||||
window.location.pathname.startsWith(`/${locale}/`)
|
||||
window.location.pathname.startsWith(`/${locale}/`),
|
||||
);
|
||||
const bestLocale = getBestLocale();
|
||||
const currentPath = locales.supported.find(({ locale }) =>
|
||||
window.location.pathname.startsWith(`/${locale}/`)
|
||||
window.location.pathname.startsWith(`/${locale}/`),
|
||||
);
|
||||
|
||||
if (
|
||||
@@ -19,8 +19,8 @@
|
||||
window.location.pathname = isI18nPath
|
||||
? window.location.pathname.replace(
|
||||
`/${currentPath?.locale}`,
|
||||
bestLocale === undefined ? "" : `/${bestLocale}`
|
||||
bestLocale === undefined ? "" : `/${bestLocale}`,
|
||||
)
|
||||
: `${bestLocale ? `/${bestLocale}` : ""}${window.location.pathname}`;
|
||||
: `${bestLocale}${window.location.pathname}`;
|
||||
}
|
||||
</script>
|
||||
@@ -5,11 +5,11 @@ export function getBestLocale() {
|
||||
localStorage.getItem("preferred-locale") ??
|
||||
navigator.language.split("-")[0];
|
||||
const isSupported = locales.supported.some(
|
||||
({ locale }) => locale === desiredLocale
|
||||
({ locale }) => locale === desiredLocale,
|
||||
);
|
||||
const isDefault = desiredLocale === locales.default;
|
||||
|
||||
if (!isSupported || isDefault) return undefined;
|
||||
if (!isSupported || isDefault) return locales.default;
|
||||
|
||||
return desiredLocale;
|
||||
}
|
||||
@@ -12,7 +12,8 @@ export const getStaticPaths = (async () => {
|
||||
.map((tank) =>
|
||||
parentPaths.map((parent) => ({
|
||||
params: { ...parent.params, id: tank.id },
|
||||
}))
|
||||
props: parent.props,
|
||||
})),
|
||||
)
|
||||
.flat();
|
||||
}) satisfies GetStaticPaths;
|
||||
|
||||
Reference in new issue
Block a user