diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b4cfc4..1091e0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,22 @@ # Changelog +## v0.1.10 + +[compare changes](https://github.com/rezozero/nuxt-stories/compare/v0.1.9...v0.1.10) + +### 🚀 Enhancements + +- Handle layers ([044ffac](https://github.com/rezozero/nuxt-stories/commit/044ffac)) + +### 📖 Documentation + +- Add caveats section to the readme ([499ffcf](https://github.com/rezozero/nuxt-stories/commit/499ffcf)) + +### ❤️ Contributors + +- Manuel Odelain + ## v0.1.9 [compare changes](https://github.com/rezozero/nuxt-stories/compare/v0.1.8...v0.1.9) diff --git a/README.md b/README.md index b017692..e997ec8 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,12 @@ npm run test:watch npm run release ``` +## Caveats + +The app must use Nuxt layout. +Behind the scene, this module will use a layout `stories` (automatically injected) to display the stories. +At least, the app must have a `default` layout. That is how the layout can be switched by the module. + [npm-version-src]: https://img.shields.io/npm/v/@rezo-zero/nuxt-stories/latest.svg?style=flat&colorA=020420&colorB=00DC82 [npm-version-href]: https://npmjs.com/package/@rezo-zero/nuxt-stories diff --git a/package.json b/package.json index 09c25aa..99dffb3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rezo-zero/nuxt-stories", - "version": "0.1.9", + "version": "0.1.10", "description": "Nuxt stories module - a kind of ultra light Storybook", "repository": { "type": "git", diff --git a/playground/nuxt.config.ts b/playground/nuxt.config.ts index 345b236..fcf1f32 100644 --- a/playground/nuxt.config.ts +++ b/playground/nuxt.config.ts @@ -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'], }) diff --git a/src/module.ts b/src/module.ts index 8d9c0de..b250647 100644 --- a/src/module.ts +++ b/src/module.ts @@ -84,14 +84,24 @@ export default defineNuxtModule({ // 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) })