diff --git a/addons/docs/src/mdx/__snapshots__/mdx-compiler-plugin.test.js.snap b/addons/docs/src/mdx/__snapshots__/mdx-compiler-plugin.test.js.snap index 9644bb08c6a8..76cfd8a74090 100644 --- a/addons/docs/src/mdx/__snapshots__/mdx-compiler-plugin.test.js.snap +++ b/addons/docs/src/mdx/__snapshots__/mdx-compiler-plugin.test.js.snap @@ -511,6 +511,9 @@ function MDXContent({ components, ...props }) { + + + ); } @@ -532,12 +535,21 @@ wPunctuation.story = {}; wPunctuation.story.name = 'w/punctuation'; wPunctuation.story.parameters = { mdxSource: '' }; -const componentMeta = { title: 'Button', includeStories: ['one', 'helloStory', 'wPunctuation'] }; +export const _1FineDay = () => ; +_1FineDay.story = {}; +_1FineDay.story.name = '1 fine day'; +_1FineDay.story.parameters = { mdxSource: '' }; + +const componentMeta = { + title: 'Button', + includeStories: ['one', 'helloStory', 'wPunctuation', '_1FineDay'], +}; const mdxStoryNameToId = { one: 'button--one', 'hello story': 'button--hello-story', 'w/punctuation': 'button--w-punctuation', + '1 fine day': 'button--1-fine-day', }; componentMeta.parameters = componentMeta.parameters || {}; diff --git a/addons/docs/src/mdx/__testfixtures__/story-definitions.mdx b/addons/docs/src/mdx/__testfixtures__/story-definitions.mdx index 74dc5db7a0d2..b50bb0df7e2c 100644 --- a/addons/docs/src/mdx/__testfixtures__/story-definitions.mdx +++ b/addons/docs/src/mdx/__testfixtures__/story-definitions.mdx @@ -16,3 +16,7 @@ import { Story, Meta } from '@storybook/addon-docs/blocks'; + + + + diff --git a/addons/docs/src/mdx/mdx-compiler-plugin.js b/addons/docs/src/mdx/mdx-compiler-plugin.js index e21ef8fdd581..e72c5c548ade 100644 --- a/addons/docs/src/mdx/mdx-compiler-plugin.js +++ b/addons/docs/src/mdx/mdx-compiler-plugin.js @@ -19,10 +19,13 @@ function getAttr(elt, what) { } const isReserved = name => RESERVED.exec(name); +const startsWithNumber = name => /^\d/.exec(name); const sanitizeName = name => { let key = camelCase(name); - if (isReserved(key)) { + if (startsWithNumber(key)) { + key = `_${key}`; + } else if (isReserved(key)) { key = `${key}Story`; } return key;