fix: store augmented pages with file path

This commit is contained in:
Alexander Lichter 2024-06-25 18:31:21 +02:00
parent 9d3b43a6c8
commit 59d0d2de7a
1 changed files with 4 additions and 4 deletions

View File

@ -140,19 +140,19 @@ export function generateRoutesFromFiles (files: ScannedFile[], options: Generate
return prepareRoutes(routes)
}
export async function augmentPages (routes: NuxtPage[], vfs: Record<string, string>, augmentedPages = new Set<string>()) {
export async function augmentPages (routes: NuxtPage[], vfs: Record<string, string>, augmentedPagesWithPaths = new Set<string>()) {
for (const route of routes) {
if (route.file && !augmentedPages.has(route.file)) {
if (route.file && !augmentedPagesWithPaths.has(route.file)) {
const fileContent = route.file in vfs ? vfs[route.file] : fs.readFileSync(await resolvePath(route.file), 'utf-8')
Object.assign(route, await getRouteMeta(fileContent, route.file))
augmentedPages.add(route.file)
augmentedPagesWithPaths.add(`${route.file}_${route.path}`)
}
if (route.children && route.children.length > 0) {
await augmentPages(route.children, vfs)
}
}
return augmentedPages
return augmentedPagesWithPaths
}
const SFC_SCRIPT_RE = /<script(?<attrs>[^>]*)>(?<content>[\s\S]*?)<\/script[^>]*>/i