Hide Docs tab in Storybook

旧时模样 提交于 2021-02-08 08:23:21

问题


I want to create stories using both Typescript and MDX, therefore I have in my main.js:

module.exports = {
  stories: ['../src/**/*.stories.(mdx|ts)'],
  addons: ['@storybook/addon-docs', 'storybook-addon-preview']
};

However I don't want to have "Docs" tab next to "Canvas". How do I remove it? Without '@storybook/addon-docs' MDX story is not displayed.


回答1:


Put this in preview.js:

export const parameters = {
  previewTabs: {
    'storybook/docs/panel': {
      hidden: true
    }
  }
};

Used in Storybook version 6.0.x




回答2:


I am currently using @storybook/angular@6.0.21 and the previous answer unfortunately did not work for me. I was able to find a solution in the storybook DocsPage documentation.

The relevant section:

You can replace DocsPage at any level by overriding the docs.page parameter:

- With null to remove docs
- With MDX docs
- With a custom React component

I was able to completely remove the DocsPage for a single story like this:

export const myStory = () => ({
  moduleMetadata: MODULE_METADATA,
  component: MyComponent,
});
myStory.parameters = {
  docs: { page: null },
};


来源:https://stackoverflow.com/questions/63499683/hide-docs-tab-in-storybook

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!