mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 11:11:53 +08:00
34 lines
986 B
Plaintext
34 lines
986 B
Plaintext
```ts
|
|
// .storybook/main.ts
|
|
|
|
// Replace your-framework with the framework you are using (e.g., react-webpack5, vue3-vite)
|
|
import type { StorybookConfig } from '@storybook/your-framework';
|
|
import type { Indexer } from '@storybook/types';
|
|
|
|
const combosIndexer: Indexer = {
|
|
test: /\.stories\.[tj]sx?$/,
|
|
createIndex: async (fileName, { makeTitle }) => {
|
|
// 👇 Grab title from fileName
|
|
const title = fileName.match(/\/(.*)\.stories/)[1];
|
|
|
|
// Read file and generate entries ...
|
|
|
|
return entries.map((entry) => ({
|
|
type: 'story',
|
|
// 👇 Use makeTitle to format the title
|
|
title: `${makeTitle(title)} Custom`,
|
|
importPath: fileName,
|
|
exportName: entry.name,
|
|
}));
|
|
},
|
|
};
|
|
|
|
const config: StorybookConfig = {
|
|
framework: '@storybook/your-framework',
|
|
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
|
|
experimental_indexers: async (existingIndexers) => [...existingIndexers, combosIndexer];
|
|
};
|
|
|
|
export default config;
|
|
```
|