mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-21 21:25:11 +00:00
refactor: use parent path
This commit is contained in:
parent
59d0d2de7a
commit
a7dde60be2
@ -140,16 +140,16 @@ export function generateRoutesFromFiles (files: ScannedFile[], options: Generate
|
||||
return prepareRoutes(routes)
|
||||
}
|
||||
|
||||
export async function augmentPages (routes: NuxtPage[], vfs: Record<string, string>, augmentedPagesWithPaths = new Set<string>()) {
|
||||
export async function augmentPages (routes: NuxtPage[], vfs: Record<string, string>, augmentedPagesWithPaths = new Set<string>(), parentPath = '') {
|
||||
for (const route of routes) {
|
||||
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))
|
||||
augmentedPagesWithPaths.add(`${route.file}_${route.path}`)
|
||||
augmentedPagesWithPaths.add(`${route.file}_${parentPath}${route.path}`)
|
||||
}
|
||||
|
||||
if (route.children && route.children.length > 0) {
|
||||
await augmentPages(route.children, vfs)
|
||||
await augmentPages(route.children, vfs, augmentedPagesWithPaths, route.path)
|
||||
}
|
||||
}
|
||||
return augmentedPagesWithPaths
|
||||
|
Loading…
Reference in New Issue
Block a user