managerHead
类型:(head: string) => string
以编程方式调整 Storybook 管理器的 <head>
。例如,加载自定义字体或添加脚本。最常用于 插件作者。
如果您不需要以编程方式调整管理器头部,则可以改为将脚本和样式添加到 manager-head.html
中。
例如,您可以根据环境有条件地添加脚本或样式
.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)'],
managerHead: (head) => `
${head}
<link rel="preload" href="/fonts/my-custom-manager-font.woff2" />
`,
};
export default config;