https://github.com/Extarys/nuxt-nested-routes-hook
How can I use pages:extend hook with nested pages?
Right now it seems kind of broken :/ The parent page is not rendered, but the content of the nested top page is. How can I control this behavior?
2 messages · Page 1 of 1 (latest)
https://github.com/Extarys/nuxt-nested-routes-hook
How can I use pages:extend hook with nested pages?
Right now it seems kind of broken :/ The parent page is not rendered, but the content of the nested top page is. How can I control this behavior?
@hasty cradle Here's an implementation that works for me via a custom Nuxt Module.
import { defineNuxtModule } from '@nuxt/kit'
import path from 'node:path'
import { glob } from 'glob'
export default defineNuxtModule({
hooks: {
async 'pages:extend'(pages) {
const routesFilesPaths = await glob('./src/views/**/*.routes.ts')
const routes = await Promise.all(
routesFilesPaths.map(routesFilePath => {
return import(path.join(path.resolve(), routesFilePath))
})
)
pages.push(...routes.flat(1))
},
},
})