fix: sync language prefixes
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
homePathForLang,
|
||||
isHomePathname,
|
||||
languageFromPathname,
|
||||
localizePath,
|
||||
stripLangPrefix,
|
||||
} from "../languageRoutes";
|
||||
import { useLocalizedPath } from "../useLocalizedPath";
|
||||
@@ -318,7 +319,15 @@ export function PublicLayout() {
|
||||
const homePath = homePathForLang(lang);
|
||||
const changeLang = (nextLang: Lang) => {
|
||||
setLang(nextLang);
|
||||
if (isHome) nav(homePathForLang(nextLang), { replace: true });
|
||||
if (isHome) {
|
||||
nav(homePathForLang(nextLang), { replace: true });
|
||||
} else {
|
||||
// Preserve sub-path and query/hash; only swap the language prefix.
|
||||
const canonical = stripLangPrefix(pathname);
|
||||
nav(localizePath(canonical, nextLang) + search + hash, {
|
||||
replace: true,
|
||||
});
|
||||
}
|
||||
};
|
||||
const footerInContentFlow = stripLangPrefix(pathname) === "/browse";
|
||||
// Current page name shown in the header brand slot (falls back to the brand).
|
||||
|
||||
Reference in New Issue
Block a user