codehike icon indicating copy to clipboard operation
codehike copied to clipboard

Docs: Storybook 7 config example

Open NikitaIT opened this issue 2 years ago • 2 comments

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;
  },
};

NikitaIT avatar Feb 10 '23 23:02 NikitaIT

hi, what's the issue?

pomber avatar Feb 13 '23 10:02 pomber

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

NikitaIT avatar Mar 07 '23 21:03 NikitaIT