Schlagwort: SyntaxError

  • Importing Markdown in MDX

    Ever imported Markdown in Storybook into an MDX?
    I tried the following (in Storybook 7) and it was failing with an Error, that I was not able to find when searching for it:

    import StorybookChangeset from './CHANGELOG.md';
    
    # Changelog
    
    <StorybookChangeset />Code-Sprache: JavaScript (javascript)

    This returned with the following issue:

    SyntaxError: '#' not followed by identifierCode-Sprache: Bash (bash)

    So I was wondering what the issue was, and Alexis Charpentier had the matching solution:

    import { Markdown } from '@storybook/addon-docs';
    import StorybookChangeset from '../../../CHANGELOG.md?raw';
    
    # Changelog
    
    <Markdown>{StorybookChangeset}</Markdown>Code-Sprache: JavaScript (javascript)

    Hope this helps you!