Skip to content

Commit 7615b62

Browse files
authoredJul 29, 2024··
fix useRouter in nextra/hooks, use asPath instead route because locale can be dynamic /[locale] (#3075)
aa
1 parent bc1cc6d commit 7615b62

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
 

‎.changeset/pink-dingos-serve.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'nextra': patch
3+
---
4+
5+
fix `useRouter` in `nextra/hooks`, use `asPath` instead `route` because locale can be dynamic `/[locale]`

‎packages/nextra/src/client/hooks/use-router.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const useRouter: typeof useNextRouter = () => {
99
return {
1010
...router,
1111
defaultLocale,
12-
...(defaultLocale && { locale: router.route.split('/')[1] })
12+
...(defaultLocale && { locale: router.asPath.split('/')[1] })
1313
}
1414
}, [router])
1515
}

0 commit comments

Comments
 (0)
Please sign in to comment.