API
Config Hook
As of Version 3 @nuxtjs/storybook
will provide API for modules to modify Storybook config and add their own stories. Modules can use storybook:config
hook to access Storybook config and add their own stories.
It is highly recommended to create your stories under
Modules
. This is best way to keep storybook cleen. Take a look at below example. Read more about naming
Here is a sample example:
your-awesome-module/index.js
export default function() {
const { nuxt } = this
nuxt.hook('storybook:config', ({ stories }) => {
stories.push("your-awesome-module/stories/*.stories.js")
})
}
your-awesome-module/stories/awesome.stories.js
export default {
title: "Moduels/Awesome Module"
}
export const awesomeStory = () => "<div>AWESOME</div>"
Just like that, now everyone that uses your-awesome-module
will see your story inside Storybook.