From 941b2fe8a5c45e1065b9a1f0b0541e571b43f26d Mon Sep 17 00:00:00 2001 From: "Mr.Hope" Date: Wed, 28 Dec 2022 16:55:38 +0800 Subject: [PATCH] fix(theme-default): preserve url params when switching language (#1211) --- .../theme-default/src/client/components/NavbarItems.vue | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ecosystem/theme-default/src/client/components/NavbarItems.vue b/ecosystem/theme-default/src/client/components/NavbarItems.vue index 1059eed712..9d64ad3dc4 100644 --- a/ecosystem/theme-default/src/client/components/NavbarItems.vue +++ b/ecosystem/theme-default/src/client/components/NavbarItems.vue @@ -31,7 +31,6 @@ const useNavbarSelectLanguage = (): ComputedRef => { } const currentPath = router.currentRoute.value.path const currentFullPath = router.currentRoute.value.fullPath - const currentHash = router.currentRoute.value.hash const languageDropdown: ResolvedNavbarItem = { text: themeLocale.value.selectLanguageText ?? 'unknown language', @@ -65,8 +64,8 @@ const useNavbarSelectLanguage = (): ComputedRef => { if ( router.getRoutes().some((item) => item.path === targetLocalePage) ) { - // try to keep current hash across languages - link = `${targetLocalePage}${currentHash}` + // try to keep current hash and params across languages + link = currentFullPath.replace(currentPath, targetLocalePage) } else { link = targetThemeLocale.home ?? targetLocalePath }