Skip to content

Commit

Permalink
feat(theme-default): preserve query string on locale change (#809)
Browse files Browse the repository at this point in the history
  • Loading branch information
ambar authored Mar 19, 2024
1 parent 1d5ebc7 commit d27c2e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/little-dots-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rspress/theme-default": minor
---

feat(theme-default): preserve query string on locale change
4 changes: 2 additions & 2 deletions packages/theme-default/src/components/Nav/menuDataHooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SvgWrapper } from '../SvgWrapper';
export function useTranslationMenuData() {
const { siteData, page } = usePageData();
const currentVersion = useVersion();
const { pathname } = useLocation();
const { pathname, search } = useLocation();
const defaultLang = siteData.lang || '';
const defaultVersion = siteData.multiVersion.default || '';
const localeLanguages = Object.values(
Expand All @@ -31,7 +31,7 @@ export function useTranslationMenuData() {
items: localeLanguages.map(item => ({
text: item?.label,
link: replaceLang(
pathname,
pathname + search,
{
current: currentLang,
target: item.lang,
Expand Down

0 comments on commit d27c2e2

Please sign in to comment.