Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Storybook 7 config example #325

Open
NikitaIT opened this issue Feb 10, 2023 · 2 comments
Open

Docs: Storybook 7 config example #325

NikitaIT opened this issue Feb 10, 2023 · 2 comments

Comments

@NikitaIT
Copy link

Styles fix

Wrap all components in class sb-unstyled. In fact, I'm happy with the situation in which only my styles are applied on the page.

<Meta of={BannerStories} />
<div className="sb-unstyled">
# h1
          <CH.Code>
          
          \`\`\`python one.py
          print("Hello, one!")
          \`\`\`
          
          \`\`\`python two.py
          print("Hello, two!")
          \`\`\`
          
          </CH.Code>
</div>

Config with remarkPlugins

// .storybook/preview.ts
import '@code-hike/mdx/styles.css';
// .storybook/main.ts
import type { StorybookConfig } from '@storybook/react-webpack5';
import { remarkCodeHike } from '@code-hike/mdx';
import theme from 'shiki/themes/dark-plus.json' assert { type: 'json' };

export const config: StorybookConfig = {
  stories: ['../src/**/*.stories.@(js|jsx|ts|tsx|mdx)', '../src/**/*.@(mdx)'],
  addons: ['@storybook/addon-essentials', '@nrwl/react/plugins/storybook'],
  framework: {
    name: '@storybook/react-webpack5',
    options: {},
  },
  webpackFinal: async (config, options) => {
    const rule = (config.module?.rules || []).find((rule) =>
      typeof rule != 'string'
        ? rule.test?.toString().endsWith('\\.mdx$/')
        : false
    );
    (rule as any).use[0].options.mdxCompileOptions.remarkPlugins.push([
      remarkCodeHike,
      { theme, lineNumbers: false, showCopyButton: true },
    ]);
    return config;
  },
};
@pomber
Copy link
Contributor

pomber commented Feb 13, 2023

hi, what's the issue?

@NikitaIT
Copy link
Author

NikitaIT commented Mar 7, 2023

@pomber I just shared a configuration example that is not in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants