mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
feat(nuxt): respect custom dir.pages
in page placeholder (#20079)
This commit is contained in:
parent
bf8fe61b33
commit
bc9c7dcac8
@ -278,7 +278,10 @@ export const publicPathTemplate: NuxtTemplate = {
|
|||||||
export const nuxtConfigTemplate = {
|
export const nuxtConfigTemplate = {
|
||||||
filename: 'nuxt.config.mjs',
|
filename: 'nuxt.config.mjs',
|
||||||
getContents: (ctx: TemplateContext) => {
|
getContents: (ctx: TemplateContext) => {
|
||||||
return Object.entries(ctx.nuxt.options.app).map(([k, v]) => `export const ${camelCase('app-' + k)} = ${JSON.stringify(v)}`).join('\n\n')
|
return [
|
||||||
|
...Object.entries(ctx.nuxt.options.app).map(([k, v]) => `export const ${camelCase('app-' + k)} = ${JSON.stringify(v)}`),
|
||||||
|
`export const devPagesDir = ${ctx.nuxt.options.dev ? JSON.stringify(ctx.nuxt.options.dir.pages) : 'null'}`
|
||||||
|
].join('\n\n')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import { defineComponent } from 'vue'
|
import { defineComponent } from 'vue'
|
||||||
|
// @ts-expect-error virtual file
|
||||||
|
import { devPagesDir } from '#build/nuxt.config.mjs'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'NuxtPage',
|
name: 'NuxtPage',
|
||||||
setup (_, props) {
|
setup (_, props) {
|
||||||
if (process.dev) {
|
if (process.dev) {
|
||||||
console.warn('Create a Vue component in the `pages/` directory to enable `<NuxtPage>`')
|
console.warn(`Create a Vue component in the \`${devPagesDir}/\` directory to enable \`<NuxtPage>\``)
|
||||||
}
|
}
|
||||||
return () => props.slots.default?.()
|
return () => props.slots.default?.()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user