文件
類型
{
autodocs?: boolean | 'tag';
defaultName?: string;
docsMode?: boolean;
}
設定 Storybook 的自動產生的文件。
autodocs
類型:boolean | 'tag'
預設值:'tag'
啟用或停用 story 的自動文件。
true
:為所有 story 啟用false
:為所有 story 停用'tag'
:為標記為'autodocs'
的 story 啟用
.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';
const config: StorybookConfig = {
framework: '@storybook/your-framework',
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
docs: {
autodocs: 'tag',
},
};
export default config;
defaultName
類型:string
預設值:'Docs'
用於產生文件頁面的名稱。
.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';
const config: StorybookConfig = {
framework: '@storybook/your-framework',
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
docs: {
defaultName: 'Documentation',
},
};
export default config;
docsMode
類型:boolean
僅在側邊欄中顯示文件頁面(通常使用 --docs
CLI 標誌設定)。
.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';
const config: StorybookConfig = {
framework: '@storybook/your-framework',
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
docs: {
docsMode: true,
},
};
export default config;