mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +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 isAPI = window.location.pathname.startsWith("/api");
|
||||||
const isI18nPath = locales.supported.some(({ locale }) =>
|
const isI18nPath = locales.supported.some(({ locale }) =>
|
||||||
window.location.pathname.startsWith(`/${locale}/`)
|
window.location.pathname.startsWith(`/${locale}/`),
|
||||||
);
|
);
|
||||||
const bestLocale = getBestLocale();
|
const bestLocale = getBestLocale();
|
||||||
const currentPath = locales.supported.find(({ locale }) =>
|
const currentPath = locales.supported.find(({ locale }) =>
|
||||||
window.location.pathname.startsWith(`/${locale}/`)
|
window.location.pathname.startsWith(`/${locale}/`),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -19,8 +19,8 @@
|
|||||||
window.location.pathname = isI18nPath
|
window.location.pathname = isI18nPath
|
||||||
? window.location.pathname.replace(
|
? window.location.pathname.replace(
|
||||||
`/${currentPath?.locale}`,
|
`/${currentPath?.locale}`,
|
||||||
bestLocale === undefined ? "" : `/${bestLocale}`
|
bestLocale === undefined ? "" : `/${bestLocale}`,
|
||||||
)
|
)
|
||||||
: `${bestLocale ? `/${bestLocale}` : ""}${window.location.pathname}`;
|
: `${bestLocale}${window.location.pathname}`;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -5,11 +5,11 @@ export function getBestLocale() {
|
|||||||
localStorage.getItem("preferred-locale") ??
|
localStorage.getItem("preferred-locale") ??
|
||||||
navigator.language.split("-")[0];
|
navigator.language.split("-")[0];
|
||||||
const isSupported = locales.supported.some(
|
const isSupported = locales.supported.some(
|
||||||
({ locale }) => locale === desiredLocale
|
({ locale }) => locale === desiredLocale,
|
||||||
);
|
);
|
||||||
const isDefault = desiredLocale === locales.default;
|
const isDefault = desiredLocale === locales.default;
|
||||||
|
|
||||||
if (!isSupported || isDefault) return undefined;
|
if (!isSupported || isDefault) return locales.default;
|
||||||
|
|
||||||
return desiredLocale;
|
return desiredLocale;
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,8 @@ export const getStaticPaths = (async () => {
|
|||||||
.map((tank) =>
|
.map((tank) =>
|
||||||
parentPaths.map((parent) => ({
|
parentPaths.map((parent) => ({
|
||||||
params: { ...parent.params, id: tank.id },
|
params: { ...parent.params, id: tank.id },
|
||||||
}))
|
props: parent.props,
|
||||||
|
})),
|
||||||
)
|
)
|
||||||
.flat();
|
.flat();
|
||||||
}) satisfies GetStaticPaths;
|
}) satisfies GetStaticPaths;
|
||||||
|
|||||||
Reference in new issue
Block a user