mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
UI: fix i18n toggle
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'fumadocs-ui': patch
|
||||
---
|
||||
|
||||
Fix i18n toggle
|
||||
@@ -43,14 +43,14 @@ export function I18nProvider({
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
|
||||
const onChangeCallback = (locale: string) => {
|
||||
const onChangeCallback = (value: string) => {
|
||||
const segments = pathname.split('/').filter((v) => v.length > 0);
|
||||
|
||||
// If locale prefix hidden
|
||||
if (segments[0] !== locale) {
|
||||
segments.unshift(locale);
|
||||
segments.unshift(value);
|
||||
} else {
|
||||
segments[0] = locale;
|
||||
segments[0] = value;
|
||||
}
|
||||
|
||||
router.push(`/${segments.join('/')}`);
|
||||
|
||||
Reference in New Issue
Block a user