文件
Storybook 文件

文件

父層: main.js|ts 設定

類型

{
  autodocs?: boolean | 'tag';
  defaultName?: string;
  docsMode?: boolean;
}

設定 Storybook 的自動產生文件功能。

autodocs

類型: boolean | 'tag'

預設值: 'tag'

啟用或停用 stories 的自動文件功能。

  • true:為所有 stories 啟用
  • false:為所有 stories 停用
  • 'tag':為標記 'autodocs' 的 stories 啟用
.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

預設值: '文件'

用於產生文件頁面的名稱。

.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;