Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(theme-default): preserve url params when switching language #1211

Merged
merged 1 commit into from Dec 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions ecosystem/theme-default/src/client/components/NavbarItems.vue
Expand Up @@ -31,7 +31,6 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
}
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',
Expand Down Expand Up @@ -65,8 +64,8 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
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
}
Expand Down