fix(nuxt): use file path as key for re-augmenting

This commit is contained in:
Daniel Roe 2024-06-11 09:37:35 +01:00
parent b75bf870be
commit 09f6a88e1d
No known key found for this signature in database
GPG Key ID: CBC814C393D93268

View File

@ -139,12 +139,12 @@ export function generateRoutesFromFiles (files: ScannedFile[], options: Generate
return prepareRoutes(routes) return prepareRoutes(routes)
} }
export async function augmentPages (routes: NuxtPage[], vfs: Record<string, string>, augmentedPages = new Set<NuxtPage>()) { export async function augmentPages (routes: NuxtPage[], vfs: Record<string, string>, augmentedPages = new Set<string>()) {
for (const route of routes) { for (const route of routes) {
if (!augmentedPages.has(route) && route.file) { if (route.file && !augmentedPages.has(route.file)) {
const fileContent = route.file in vfs ? vfs[route.file] : fs.readFileSync(await resolvePath(route.file), 'utf-8') 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)) Object.assign(route, await getRouteMeta(fileContent, route.file))
augmentedPages.add(route) augmentedPages.add(route.file)
} }
if (route.children && route.children.length > 0) { if (route.children && route.children.length > 0) {