Skip to content

Commit

Permalink
feat: handle layers
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelodelain committed Feb 23, 2024
1 parent 499ffcf commit 044ffac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion playground/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default defineNuxtConfig({
devtools: { enabled: true },
modules: ['../src/module'],
// modules: ['../src/module'],
css: ['~/assets/css/main.css'],
extends: ['github:rezozero/nuxt-layer'],
})
10 changes: 10 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,24 @@ export default defineNuxtModule<NuxtStoriesOptions>({

// PAGES
extendPages(async (pages) => {
// scan project files
const files = await resolveFiles(nuxt.options.rootDir, pattern)

// scan layers files
const layersFiles = await Promise.all(
nuxt.options._layers.map((layer) => resolveFiles(layer.config.rootDir, pattern)),
)

files.concat(layersFiles.flat())

// generate child routes
files.forEach((file) => {
const fileRoute = getFileRoute(file)

route.children!.push(fileRoute)
})

// add route
pages.push(route)
})

Expand Down

0 comments on commit 044ffac

Please sign in to comment.