From f694c269c11e975381dcf9376acb90d6f6213eda Mon Sep 17 00:00:00 2001 From: Valentin Agachi Date: Fri, 2 Apr 2021 13:36:21 +0200 Subject: [PATCH] Document support for stories as function Source: https://github.com/storybookjs/storybook/issues/11181#issuecomment-674844736 --- docs/configure/overview.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/configure/overview.md b/docs/configure/overview.md index b4d0f1cd284d..8a31521c6da8 100644 --- a/docs/configure/overview.md +++ b/docs/configure/overview.md @@ -60,6 +60,21 @@ For example if you wanted to pull both `.md` and `.js` files from the `my-projec +If you want to use a custom logic for loading stories which is not supported by a glob pattern, you can supply the final list of stories files: + +```js +// .storybook/main.js + +function findStories() { + // your custom logic returns a list of files +} + +module.exports = { + stories: async (list) => [...list, ...findStories()], +}; +``` + + ## Configure story rendering To control the way stories are rendered and add global [decorators](../writing-stories/decorators.md#global-decorators) and [parameters](../writing-stories/parameters.md#global-parameters), create a `.storybook/preview.js` file. This is loaded in the Canvas tab, the “preview” iframe that renders your components in isolation. Use `preview.js` for global code (such as [CSS imports](../get-started/setup.md#render-component-styles) or JavaScript mocks) that applies to all stories.