question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to embed mdx/md documents within mdx doc page stories

See original GitHub issue

Describe the bug An error is received when attempting to embed markdown documents within a doc page story (mdx file). Error states Failed to execute 'createElement' on 'Document': The tag name provided ('# Markdown File....

To Reproduce Steps to reproduce the behavior:

  1. Use below code along with a markdown file within story
  2. Navigate to story
  3. Open docs page
  4. View error

Expected behavior I would expect the content of the markdown file to be embedded within the mdx file content.

Screenshots If applicable, add screenshots to help explain your problem. image

Code snippets Sample Content of my mdx file


import { moduleMetadata } from '@storybook/angular';
import { Story, Meta } from '@storybook/addon-docs/blocks';
import { MatCardModule } from '@angular/material/card';

import Overview from './docs/overview.md';

<Meta
  title="Experience/Components"
  decorators={
    [
      moduleMetadata(
        {
          imports: [
            MatCardModule,
          ],
        }
      ),
    ]
    }
/>

<Overview />


<Story name="Card">
  {{
    template: `
      <div style="padding: 10px">
        <mat-card>Simple card</mat-card>
      </div>
      `,
  }}
</Story>

Sample Content of my md file


# Markdown File

This is a markdown file...


System:


Environment Info:
  System:
    OS: Windows 10
    CPU: (8) x64 Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
  Binaries:
    Node: 10.15.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.16.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 41.16299.1004.0


    "@storybook/addon-a11y": "5.2.0-beta.18",
    "@storybook/addon-actions": "5.2.0-beta.18",
    "@storybook/addon-docs": "5.2.0-beta.18",
    "@storybook/addon-knobs": "5.2.0-beta.18",
    "@storybook/addon-links": "5.2.0-beta.18",
    "@storybook/addon-notes": "5.2.0-beta.18",
    "@storybook/addon-viewport": "5.2.0-beta.18",
    "@storybook/addons": "5.2.0-beta.18",
    "@storybook/angular": "5.2.0-beta.18",

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:18
  • Comments:35 (14 by maintainers)

github_iconTop GitHub Comments

24reactions
Hicksmixcommented, Feb 27, 2020

Hello there,

I was also stuck on this problem for a while, until I found something that works for me:

test.md:

# Test

This is just an example of a Markdown for my first ever Github comment. 
I hope it can help some people.

test.stories.mdx:

import { Meta, Description } from '@storybook/addon-docs/blocks';
import test from './test.md';

<Meta title="Test"/>

<Description>{test}</Description>

I hope this is helps.

13reactions
williamliangwlcommented, Mar 26, 2021

Not sure if you guys have successfully used this feature. What I did to get my MD files to be embeded, is by doing the followings:

Storybook version: 6.1.21

.storybook/main.js

addons: [
    "@storybook/addon-links",
    "@storybook/addon-essentials",
    // add the followings
    {
      name: "@storybook/addon-docs",
      options: { transcludeMarkdown: true },
    },
],

I followed the example from here https://github.com/storybookjs/storybook/pull/11334/files

Read more comments on GitHub >

github_iconTop Results From Across the Web

MDX - Storybook
Embedding stories. Suppose you have an existing story and want to embed it into your docs. Here's how to show a story with...
Read more >
Getting started - MDX
This article explains how to integrate MDX into your project. It shows how to use MDX with your bundler and JSX runtime of...
Read more >
gatsby-plugin-mdx
gatsby-plugin-mdx is the official integration for using MDX with Gatsby. MDX is markdown for the component era. It lets you write JSX embedded...
Read more >
Blogging with Gatsby & MDX - React Training
We can't really get this effect with one file like pages/blog/index.js because anything we put in pages is a 1:1 mapping to a...
Read more >
Not able to create documentation in MDX for Angular ...
So after a bit of searching I found something that works, at least my MDX doc is set up and I can see...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found