Skip to content

Commit 941b2fe

Browse files
authored
fix(theme-default): preserve url params when switching language (#1211)
1 parent 666257a commit 941b2fe

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

ecosystem/theme-default/src/client/components/NavbarItems.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
3131
}
3232
const currentPath = router.currentRoute.value.path
3333
const currentFullPath = router.currentRoute.value.fullPath
34-
const currentHash = router.currentRoute.value.hash
3534
3635
const languageDropdown: ResolvedNavbarItem = {
3736
text: themeLocale.value.selectLanguageText ?? 'unknown language',
@@ -65,8 +64,8 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
6564
if (
6665
router.getRoutes().some((item) => item.path === targetLocalePage)
6766
) {
68-
// try to keep current hash across languages
69-
link = `${targetLocalePage}${currentHash}`
67+
// try to keep current hash and params across languages
68+
link = currentFullPath.replace(currentPath, targetLocalePage)
7069
} else {
7170
link = targetThemeLocale.home ?? targetLocalePath
7271
}

0 commit comments

Comments
 (0)