mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-19 01:45:53 +00:00
fix(nuxt): pass nuxt
instance to resolvePagesRoutes
This commit is contained in:
parent
e70ef00e55
commit
2b49c5b936
@ -75,7 +75,7 @@ export default defineNuxtModule({
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
const pages = await resolvePagesRoutes()
|
const pages = await resolvePagesRoutes(nuxt)
|
||||||
if (pages.length) {
|
if (pages.length) {
|
||||||
if (nuxt.apps.default) {
|
if (nuxt.apps.default) {
|
||||||
nuxt.apps.default.pages = pages
|
nuxt.apps.default.pages = pages
|
||||||
@ -93,7 +93,7 @@ export default defineNuxtModule({
|
|||||||
}
|
}
|
||||||
|
|
||||||
nuxt.hook('app:templates', async (app) => {
|
nuxt.hook('app:templates', async (app) => {
|
||||||
app.pages = await resolvePagesRoutes()
|
app.pages = await resolvePagesRoutes(nuxt)
|
||||||
|
|
||||||
if (!nuxt.options.ssr && app.pages.some(p => p.mode === 'server')) {
|
if (!nuxt.options.ssr && app.pages.some(p => p.mode === 'server')) {
|
||||||
logger.warn('Using server pages with `ssr: false` is not supported with auto-detected component islands. Set `experimental.componentIslands` to `true`.')
|
logger.warn('Using server pages with `ssr: false` is not supported with auto-detected component islands. Set `experimental.componentIslands` to `true`.')
|
||||||
@ -178,7 +178,7 @@ export default defineNuxtModule({
|
|||||||
logs: nuxt.options.debug,
|
logs: nuxt.options.debug,
|
||||||
async beforeWriteFiles (rootPage) {
|
async beforeWriteFiles (rootPage) {
|
||||||
rootPage.children.forEach(child => child.delete())
|
rootPage.children.forEach(child => child.delete())
|
||||||
const pages = nuxt.apps.default?.pages || await resolvePagesRoutes()
|
const pages = nuxt.apps.default?.pages || await resolvePagesRoutes(nuxt)
|
||||||
if (nuxt.apps.default) {
|
if (nuxt.apps.default) {
|
||||||
nuxt.apps.default.pages = pages
|
nuxt.apps.default.pages = pages
|
||||||
}
|
}
|
||||||
|
@ -42,9 +42,7 @@ interface ScannedFile {
|
|||||||
absolutePath: string
|
absolutePath: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function resolvePagesRoutes (): Promise<NuxtPage[]> {
|
export async function resolvePagesRoutes (nuxt = useNuxt()): Promise<NuxtPage[]> {
|
||||||
const nuxt = useNuxt()
|
|
||||||
|
|
||||||
const pagesDirs = nuxt.options._layers.map(
|
const pagesDirs = nuxt.options._layers.map(
|
||||||
layer => resolve(layer.config.srcDir, (layer.config.rootDir === nuxt.options.rootDir ? nuxt.options : layer.config).dir?.pages || 'pages'),
|
layer => resolve(layer.config.srcDir, (layer.config.rootDir === nuxt.options.rootDir ? nuxt.options : layer.config).dir?.pages || 'pages'),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user