From 02b06c3e8532137ebfb4f6549e88844b9becf537 Mon Sep 17 00:00:00 2001 From: joshwooding <12938082+joshwooding@users.noreply.github.com> Date: Wed, 6 Jul 2022 14:48:50 -0400 Subject: [PATCH] Fix markdown import in mdx --- README.md | 2 +- .../react/stories/mdx-in-stories/MarkdownInMDX.stories.mdx | 6 ++++++ examples/react/stories/mdx-in-stories/Test.md | 3 +++ packages/builder-vite/mdx-plugin.ts | 0 packages/builder-vite/plugins/mdx-plugin.ts | 2 +- 5 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 examples/react/stories/mdx-in-stories/MarkdownInMDX.stories.mdx create mode 100644 examples/react/stories/mdx-in-stories/Test.md delete mode 100644 packages/builder-vite/mdx-plugin.ts diff --git a/README.md b/README.md index 85dd06a2..14c0101a 120000 --- a/README.md +++ b/README.md @@ -1 +1 @@ -packages/builder-vite/README.md \ No newline at end of file +packages/builder-vite/README.md diff --git a/examples/react/stories/mdx-in-stories/MarkdownInMDX.stories.mdx b/examples/react/stories/mdx-in-stories/MarkdownInMDX.stories.mdx new file mode 100644 index 00000000..6d06bbbf --- /dev/null +++ b/examples/react/stories/mdx-in-stories/MarkdownInMDX.stories.mdx @@ -0,0 +1,6 @@ +import { Meta } from '@storybook/addon-docs'; +import Test from './Test.md'; + + + + diff --git a/examples/react/stories/mdx-in-stories/Test.md b/examples/react/stories/mdx-in-stories/Test.md new file mode 100644 index 00000000..ea049ec4 --- /dev/null +++ b/examples/react/stories/mdx-in-stories/Test.md @@ -0,0 +1,3 @@ +# Test File + +This is a test for Markdown in MDX. diff --git a/packages/builder-vite/mdx-plugin.ts b/packages/builder-vite/mdx-plugin.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/builder-vite/plugins/mdx-plugin.ts b/packages/builder-vite/plugins/mdx-plugin.ts index 9e61a1a4..7a231fbc 100644 --- a/packages/builder-vite/plugins/mdx-plugin.ts +++ b/packages/builder-vite/plugins/mdx-plugin.ts @@ -50,7 +50,7 @@ export function mdxPlugin(options: Options): Plugin { reactRefresh = reactRefreshPlugins.find((p) => p.transform); }, async transform(code, id, options) { - if (id.endsWith('.mdx')) { + if (id.match(/\.mdx?$/)) { // @ts-ignore const { compile } = features?.previewMdx2 ? await import('@storybook/mdx2-csf')