Skip to content

Commit 2d78973

Browse files
committed
Prerenderer is looking for /{locale}/__nuxt_content/content/sql_dump.txt when used with @nuxt/content
Fixes #158
1 parent 9569342 commit 2d78973

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/module.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,11 @@ export default defineNuxtModule<ModuleOptions>({
292292

293293
const fullPath = path.posix.normalize(`${parentPath}/${page.path}`) // Объединяем путь родителя и текущий путь
294294

295+
// Skip internal paths
296+
if (isInternalPath(fullPath)) {
297+
return
298+
}
299+
295300
// Проверяем наличие динамического сегмента :locale
296301
const localeSegmentMatch = fullPath.match(/:locale\(([^)]+)\)/)
297302

@@ -308,13 +313,17 @@ export default defineNuxtModule<ModuleOptions>({
308313
localizedPath = localizedPath.replace(/:locale\([^)]+\)/, localeCode)
309314

310315
// Добавляем локализованный путь в массив
311-
prerenderRoutes.push(localizedPath)
316+
if (!isInternalPath(localizedPath)) {
317+
prerenderRoutes.push(localizedPath)
318+
}
312319
}
313320
})
314321
}
315322
else {
316323
// Если в пути нет динамического сегмента локали, то просто добавляем его в массив
317-
prerenderRoutes.push(fullPath)
324+
if (!isInternalPath(fullPath)) {
325+
prerenderRoutes.push(fullPath)
326+
}
318327
}
319328

320329
// Рекурсивно обрабатываем детей, если они есть
@@ -469,6 +478,16 @@ export default defineNuxtModule<ModuleOptions>({
469478
return
470479
}
471480
const routesSet = prerenderRoutes.routes
481+
482+
// Remove internal paths before localization processing
483+
const routesToRemove: string[] = []
484+
routesSet.forEach((route) => {
485+
if (isInternalPath(route)) {
486+
routesToRemove.push(route)
487+
}
488+
})
489+
routesToRemove.forEach(route => routesSet.delete(route))
490+
472491
const additionalRoutes = new Set<string>()
473492
// Проходим по каждому существующему маршруту и добавляем локализованные версии
474493
routesSet.forEach((route) => {

src/page-manager.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const buildRouteNameFromRoute = (name: string | null | undefined, path: string |
2020
return name ?? (path ?? '').replace(/[^a-z0-9]/gi, '-').replace(/^-+|-+$/g, '')
2121
}
2222

23+
const isInternalPath = (p: string) => /(?:^|\/)__[^/]+/.test(p)
24+
2325
export class PageManager {
2426
locales: Locale[]
2527
defaultLocale: Locale
@@ -60,6 +62,11 @@ export class PageManager {
6062
const additionalRoutes: NuxtPage[] = []
6163

6264
for (const page of [...pages]) {
65+
// Skip internal paths during page processing
66+
if (page.path && isInternalPath(page.path)) {
67+
continue
68+
}
69+
6370
// if (this.isAlreadyLocalized(page.path!)) continue
6471
if (!page.name && page.file?.endsWith('.vue')) {
6572
console.warn(`[nuxt-i18n-next] Page name is missing for the file: ${page.file}`)
@@ -90,6 +97,9 @@ export class PageManager {
9097
const pagePath = page.path ?? ''
9198
const pageName = page.name ?? ''
9299

100+
// Skip removal for internal paths
101+
if (isInternalPath(pagePath)) continue
102+
93103
if (this.globalLocaleRoutes[pageName] === false) continue
94104

95105
if (!/^\/:locale/.test(pagePath) && pagePath !== '/') {

0 commit comments

Comments
 (0)