Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change to 'stories-mdx' tag to indicate a story defined in an MDX file #20417

Merged
merged 6 commits into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions code/lib/core-server/src/utils/StoryIndexGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ describe('StoryIndexGenerator', () => {
"standalone": false,
"storiesImports": Array [],
"tags": Array [
"mdx",
"stories-mdx",
"docs",
],
"title": "Page",
Expand All @@ -260,7 +260,7 @@ describe('StoryIndexGenerator', () => {
"importPath": "./src/nested/Page.stories.mdx",
"name": "StoryOne",
"tags": Array [
"mdx",
"stories-mdx",
"story",
],
"title": "Page",
Expand Down Expand Up @@ -500,7 +500,6 @@ describe('StoryIndexGenerator', () => {
],
"tags": Array [
"docs",
"mdx",
],
"title": "A",
"type": "docs",
Expand Down Expand Up @@ -614,7 +613,6 @@ describe('StoryIndexGenerator', () => {
],
"tags": Array [
"docs",
"mdx",
],
"title": "A",
"type": "docs",
Expand All @@ -629,7 +627,6 @@ describe('StoryIndexGenerator', () => {
],
"tags": Array [
"docs",
"mdx",
],
"title": "A",
"type": "docs",
Expand All @@ -653,7 +650,6 @@ describe('StoryIndexGenerator', () => {
"storiesImports": Array [],
"tags": Array [
"docs",
"mdx",
],
"title": "docs2/Yabbadabbadooo",
"type": "docs",
Expand All @@ -666,7 +662,6 @@ describe('StoryIndexGenerator', () => {
"storiesImports": Array [],
"tags": Array [
"docs",
"mdx",
],
"title": "NoTitle",
"type": "docs",
Expand Down Expand Up @@ -757,7 +752,6 @@ describe('StoryIndexGenerator', () => {
],
"tags": Array [
"docs",
"mdx",
],
"title": "A",
"type": "docs",
Expand All @@ -772,7 +766,6 @@ describe('StoryIndexGenerator', () => {
],
"tags": Array [
"docs",
"mdx",
],
"title": "A",
"type": "docs",
Expand All @@ -796,7 +789,6 @@ describe('StoryIndexGenerator', () => {
"storiesImports": Array [],
"tags": Array [
"docs",
"mdx",
],
"title": "docs2/Yabbadabbadooo",
"type": "docs",
Expand All @@ -809,7 +801,6 @@ describe('StoryIndexGenerator', () => {
"storiesImports": Array [],
"tags": Array [
"docs",
"mdx",
],
"title": "NoTitle",
"type": "docs",
Expand Down
4 changes: 2 additions & 2 deletions code/lib/core-server/src/utils/StoryIndexGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export class StoryIndexGenerator {
// We need a docs entry attached to the CSF file if either:
// a) it is a stories.mdx transpiled to CSF, OR
// b) we have docs page enabled for this file
if (componentTags.includes('mdx') || autodocsOptedIn) {
if (componentTags.includes('stories-mdx') || autodocsOptedIn) {
const name = this.options.docs.defaultName;
const id = toId(csf.meta.title, name);
entries.unshift({
Expand Down Expand Up @@ -339,7 +339,7 @@ export class StoryIndexGenerator {
importPath,
storiesImports: dependencies.map((dep) => dep.entries[0].importPath),
type: 'docs',
tags: [...(result.tags || []), 'docs', 'mdx'],
tags: [...(result.tags || []), 'docs'],
standalone: true,
};
return docsEntry;
Expand Down
18 changes: 5 additions & 13 deletions code/lib/core-server/src/utils/stories-json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ describe('useStoriesJson', () => {
],
"tags": Array [
"docs",
"mdx",
],
"title": "A",
"type": "docs",
Expand All @@ -142,7 +141,6 @@ describe('useStoriesJson', () => {
],
"tags": Array [
"docs",
"mdx",
],
"title": "A",
"type": "docs",
Expand Down Expand Up @@ -188,7 +186,6 @@ describe('useStoriesJson', () => {
"storiesImports": Array [],
"tags": Array [
"docs",
"mdx",
],
"title": "docs2/NoTitle",
"type": "docs",
Expand All @@ -201,7 +198,6 @@ describe('useStoriesJson', () => {
"storiesImports": Array [],
"tags": Array [
"docs",
"mdx",
],
"title": "docs2/Yabbadabbadooo",
"type": "docs",
Expand Down Expand Up @@ -234,7 +230,7 @@ describe('useStoriesJson', () => {
"standalone": false,
"storiesImports": Array [],
"tags": Array [
"mdx",
"stories-mdx",
"docs",
],
"title": "nested/Page",
Expand All @@ -245,7 +241,7 @@ describe('useStoriesJson', () => {
"importPath": "./src/nested/Page.stories.mdx",
"name": "StoryOne",
"tags": Array [
"mdx",
"stories-mdx",
"story",
],
"title": "nested/Page",
Expand Down Expand Up @@ -303,7 +299,6 @@ describe('useStoriesJson', () => {
"story": "docs",
"tags": Array [
"docs",
"mdx",
],
"title": "A",
},
Expand All @@ -324,7 +319,6 @@ describe('useStoriesJson', () => {
"story": "Second Docs",
"tags": Array [
"docs",
"mdx",
],
"title": "A",
},
Expand Down Expand Up @@ -394,7 +388,6 @@ describe('useStoriesJson', () => {
"story": "docs",
"tags": Array [
"docs",
"mdx",
],
"title": "docs2/NoTitle",
},
Expand All @@ -413,7 +406,6 @@ describe('useStoriesJson', () => {
"story": "docs",
"tags": Array [
"docs",
"mdx",
],
"title": "docs2/Yabbadabbadooo",
},
Expand Down Expand Up @@ -464,7 +456,7 @@ describe('useStoriesJson', () => {
"storiesImports": Array [],
"story": "docs",
"tags": Array [
"mdx",
"stories-mdx",
"docs",
],
"title": "nested/Page",
Expand All @@ -481,7 +473,7 @@ describe('useStoriesJson', () => {
},
"story": "StoryOne",
"tags": Array [
"mdx",
"stories-mdx",
"story",
],
"title": "nested/Page",
Expand Down Expand Up @@ -625,7 +617,7 @@ describe('useStoriesJson', () => {
},
"story": "StoryOne",
"tags": Array [
"mdx",
"stories-mdx",
"story",
],
"title": "nested/Page",
Expand Down
4 changes: 2 additions & 2 deletions code/lib/csf-tools/src/CsfFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ describe('CsfFile', () => {
export const TestControl = () => _jsx("p", {
children: "Hello"
});
export default { title: 'foo/bar', tags: ['mdx'], includeStories: ["__page"] };
export default { title: 'foo/bar', tags: ['stories-mdx'], includeStories: ["__page"] };
export const __page = () => {};
__page.parameters = { docsOnly: true };
`,
Expand All @@ -395,7 +395,7 @@ describe('CsfFile', () => {
meta:
title: foo/bar
tags:
- mdx
- stories-mdx
includeStories:
- __page
stories:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export class StoryStoreFacade<TRenderer extends Renderer> {
docsOptions.autodocs === true ||
(docsOptions.autodocs === 'tag' && componentTags.includes('autodocs'));
if (!docsOptions.disable && storyExports.length) {
if (componentTags.includes('mdx') || autodocsOptedIn) {
if (componentTags.includes('stories-mdx') || autodocsOptedIn) {
const name = docsOptions.defaultName;
const docsId = toId(componentId || title, name);
this.entries[docsId] = {
Expand Down
4 changes: 2 additions & 2 deletions code/lib/preview-api/src/modules/core-client/start.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ describe('start', () => {
'test',
makeRequireContext({
'./Introduction.stories.mdx': {
default: { title: 'Introduction', tags: ['mdx'] },
default: { title: 'Introduction', tags: ['stories-mdx'] },
_Page: { name: 'Page', parameters: { docsOnly: true } },
},
})
Expand All @@ -993,7 +993,7 @@ describe('start', () => {
"standalone": false,
"storiesImports": Array [],
"tags": Array [
"mdx",
"stories-mdx",
"docs",
],
"title": "Introduction",
Expand Down
6 changes: 3 additions & 3 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6812,9 +6812,9 @@ __metadata:
linkType: soft

"@storybook/mdx2-csf@npm:next":
version: 1.0.0-next.2
resolution: "@storybook/mdx2-csf@npm:1.0.0-next.2"
checksum: ebf285ee9bb27912c7e3795ef2d155d555c0f7ade15fa38b2c9e15cd590143299b890663bb2e22438ba806aaba232ead1e025ba566540d6f86047c1c2b2b44ec
version: 1.0.0-next.3
resolution: "@storybook/mdx2-csf@npm:1.0.0-next.3"
checksum: b56a458570fbe8cfdd67e2626a845b854e01b9160dc9dbcf26ed61f01b9187dbbb53c1cc4e3303d3fdb58dce7a47caf9ba2c5f83afa3284ca22ba25fecadd15c
languageName: node
linkType: hard

Expand Down