mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 01:17:16 +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 { encodePath } from 'ufo'
|
||||||
import type { Nuxt, NuxtPage } from '@nuxt/schema'
|
import type { Nuxt, NuxtPage } from '@nuxt/schema'
|
||||||
import { resolveFiles } from '@nuxt/kit'
|
import { resolveFiles } from '@nuxt/kit'
|
||||||
@ -229,13 +229,14 @@ export function normalizeRoutes (routes: NuxtPage[], metaImports: Set<string> =
|
|||||||
return {
|
return {
|
||||||
imports: metaImports,
|
imports: metaImports,
|
||||||
routes: routes.map((route) => {
|
routes: routes.map((route) => {
|
||||||
const metaImportName = `${pascalCase(route.file.replace(/[^\w]/g, ''))}Meta`
|
const file = normalize(route.file)
|
||||||
metaImports.add(`import { meta as ${metaImportName} } from '${route.file}?macro=true'`)
|
const metaImportName = `${pascalCase(file.replace(/[^\w]/g, ''))}Meta`
|
||||||
|
metaImports.add(`import { meta as ${metaImportName} } from '${file}?macro=true'`)
|
||||||
return {
|
return {
|
||||||
...route,
|
...route,
|
||||||
children: route.children ? normalizeRoutes(route.children, metaImports).routes : [],
|
children: route.children ? normalizeRoutes(route.children, metaImports).routes : [],
|
||||||
meta: route.meta || `{${metaImportName}}` as any,
|
meta: route.meta || `{${metaImportName}}` as any,
|
||||||
component: `{() => import('${route.file}')}`
|
component: `{() => import('${file}')}`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user