3
3
* This file should be never used directly, only in loader.ts
4
4
*/
5
5
6
- import { useRouter } from 'next/router'
7
6
import type { ReactElement , ReactNode } from 'react'
8
7
import { NEXTRA_INTERNAL } from '../constants.js'
9
8
import { normalizePageRoute , pageTitleFromFilename } from '../server/utils.js'
@@ -21,6 +20,7 @@ import type {
21
20
PageOpts
22
21
} from '../types'
23
22
import { DataProvider } from './data.js'
23
+ import { useRouter } from './hooks/index.js'
24
24
import { useMDXComponents } from './mdx.js'
25
25
26
26
function isFolder ( value : DynamicMetaItem ) : value is DynamicFolder {
@@ -152,7 +152,7 @@ export function HOC_MDXWrapper(
152
152
NEXTRA_INTERNAL
153
153
]
154
154
const { Layout, themeConfig } = __nextra_internal__
155
- const { route } = useRouter ( )
155
+ const { route, locale } = useRouter ( )
156
156
157
157
const pageContext = __nextra_internal__ . context [ route ]
158
158
@@ -165,8 +165,7 @@ export function HOC_MDXWrapper(
165
165
let { pageOpts } = pageContext
166
166
167
167
for ( const { route, children } of __nextra_pageMap ) {
168
- // TODO 2 for locale, 1 without local
169
- const paths = route . split ( '/' ) . slice ( 2 )
168
+ const paths = route . split ( '/' ) . slice ( locale ? 2 : 1 )
170
169
const folder = findFolder ( pageOpts . pageMap , paths )
171
170
folder . children = children
172
171
}
0 commit comments