mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
fix(nuxt3): normalize page paths ( for windows support) (#2825)
This commit is contained in:
parent
beaa369892
commit
d0d8e8311c
@ -1,4 +1,4 @@
|
||||
import { basename, extname, relative, resolve } from 'pathe'
|
||||
import { basename, extname, normalize, relative, resolve } from 'pathe'
|
||||
import { encodePath } from 'ufo'
|
||||
import type { Nuxt, NuxtPage } from '@nuxt/schema'
|
||||
import { resolveFiles } from '@nuxt/kit'
|
||||
@ -229,13 +229,14 @@ export function normalizeRoutes (routes: NuxtPage[], metaImports: Set<string> =
|
||||
return {
|
||||
imports: metaImports,
|
||||
routes: routes.map((route) => {
|
||||
const metaImportName = `${pascalCase(route.file.replace(/[^\w]/g, ''))}Meta`
|
||||
metaImports.add(`import { meta as ${metaImportName} } from '${route.file}?macro=true'`)
|
||||
const file = normalize(route.file)
|
||||
const metaImportName = `${pascalCase(file.replace(/[^\w]/g, ''))}Meta`
|
||||
metaImports.add(`import { meta as ${metaImportName} } from '${file}?macro=true'`)
|
||||
return {
|
||||
...route,
|
||||
children: route.children ? normalizeRoutes(route.children, metaImports).routes : [],
|
||||
meta: route.meta || `{${metaImportName}}` as any,
|
||||
component: `{() => import('${route.file}')}`
|
||||
component: `{() => import('${file}')}`
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user