mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 09:31:47 +08:00
- Add text representation of architectural diagram - Add/fix file name comments to snippets - Improve json stories snippets - Various tweaks to prose
34 lines
823 B
Plaintext
34 lines
823 B
Plaintext
```js
|
|
// .storybook/main.js
|
|
|
|
import fs from 'fs/promises';
|
|
|
|
const jsonStoriesIndexer = {
|
|
test: /stories\.json$/,
|
|
createIndex: async (fileName) => {
|
|
const content = JSON.parse(fs.readFileSync(fileName));
|
|
|
|
const stories = generateStoryIndexesFromJson(content);
|
|
|
|
return stories.map((story) => {
|
|
type: 'story',
|
|
importPath: `virtual:jsonstories--${fileName}--${story.componentName}`,
|
|
exportName: story.name
|
|
});
|
|
},
|
|
};
|
|
|
|
const config = {
|
|
framework: '@storybook/your-framework',
|
|
stories: [
|
|
'../src/**/*.mdx',
|
|
'../src/**/*.stories.@(js|jsx|mjs|ts|tsx)',
|
|
// 👇 Make sure files to index are included in `stories`
|
|
'../src/**/*.stories.json',
|
|
],
|
|
experimental_indexers: async (existingIndexers) => [...existingIndexers, jsonStoriesIndexer];
|
|
};
|
|
|
|
export default config;
|
|
```
|