Skip to content

Commit

Permalink
Allow MDX stories ending with stories.mdx or story.mdx (#337)
Browse files Browse the repository at this point in the history
This aligns with a change that was made in storybook 6.2 to widen the naming allowed for mdx stories: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#mdx-pattern-tweaked
  • Loading branch information
IanVS committed Apr 15, 2022
1 parent 4c38a7c commit 17abb00
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/react/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
framework: '@storybook/react',
stories: ['../stories/**/*.stories.mdx', '../stories/**/*.stories.@(js|jsx|ts|tsx)'],
stories: ['../stories/**/*stories.mdx', '../stories/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-a11y', '@storybook/addon-links', '@storybook/addon-essentials'],
core: {
builder: '@storybook/builder-vite',
Expand Down
2 changes: 1 addition & 1 deletion examples/react/stories/mdx-in-stories/Example.docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ See also [CSF Stories with arbitrary MDX](https://github.com/storybookjs/storybo
## Button

<Canvas>
<Story id="example-mdx-in-stories--primary-button" />
<Story id="examples-mdx-in-stories--primary-button" />
</Canvas>

_You should be able to see the source of the above story._
4 changes: 2 additions & 2 deletions packages/builder-vite/mdx-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createCompiler } from '@storybook/csf-tools/mdx';
/**
* Storybook uses two different loaders when dealing with MDX:
*
* - *.stories.mdx are compiled with the CSF compiler
* - *stories.mdx and *story.mdx are compiled with the CSF compiler
* - *.mdx are compiled with the MDX compiler directly
*
* @see https://github.com/storybookjs/storybook/blob/next/addons/docs/docs/recipes.md#csf-stories-with-arbitrary-mdx
Expand All @@ -13,7 +13,7 @@ export function mdxPlugin() {
return mdx((filename) => {
const compilers = [];

if (filename.includes('.stories.')) {
if (filename.endsWith('stories.mdx') || filename.endsWith('story.mdx')) {
compilers.push(createCompiler({}));
}

Expand Down

0 comments on commit 17abb00

Please sign in to comment.