diff --git a/code/addons/docs/template/stories/docspage/basic.stories.ts b/code/addons/docs/template/stories/docspage/basic.stories.ts index 36f2ca2ca7a..46d78074ecf 100644 --- a/code/addons/docs/template/stories/docspage/basic.stories.ts +++ b/code/addons/docs/template/stories/docspage/basic.stories.ts @@ -2,6 +2,7 @@ import globalThis from 'global'; export default { component: globalThis.Components.Button, + tags: ['docsPage'], args: { label: 'Click Me!' }, parameters: { chromatic: { disable: true } }, }; diff --git a/code/addons/docs/template/stories/docspage/description.stories.ts b/code/addons/docs/template/stories/docspage/description.stories.ts index 5e9dae4ab56..7eb04413a94 100644 --- a/code/addons/docs/template/stories/docspage/description.stories.ts +++ b/code/addons/docs/template/stories/docspage/description.stories.ts @@ -6,6 +6,7 @@ export default { subcomponents: { Pre: globalThis.Components.Pre, }, + tags: ['docsPage'], args: { label: 'Click Me!' }, parameters: { docs: { diff --git a/code/addons/docs/template/stories/docspage/extract-description.stories.ts b/code/addons/docs/template/stories/docspage/extract-description.stories.ts index 89bc6355f08..51ab3513c58 100644 --- a/code/addons/docs/template/stories/docspage/extract-description.stories.ts +++ b/code/addons/docs/template/stories/docspage/extract-description.stories.ts @@ -2,6 +2,7 @@ import globalThis from 'global'; export default { component: globalThis.Components.Button, + tags: ['docsPage'], args: { label: 'Click Me!' }, parameters: { docs: { diff --git a/code/addons/docs/template/stories/docspage/iframe.stories.ts b/code/addons/docs/template/stories/docspage/iframe.stories.ts index 8cd7caa65a6..df9cf977c9f 100644 --- a/code/addons/docs/template/stories/docspage/iframe.stories.ts +++ b/code/addons/docs/template/stories/docspage/iframe.stories.ts @@ -2,6 +2,7 @@ import globalThis from 'global'; export default { component: globalThis.Components.Button, + tags: ['docsPage'], args: { label: 'Rendered in iframe' }, parameters: { chromatic: { disable: true }, diff --git a/code/addons/docs/template/stories/docspage/overflow.stories.ts b/code/addons/docs/template/stories/docspage/overflow.stories.ts index 6be8604b0e1..a281100c885 100644 --- a/code/addons/docs/template/stories/docspage/overflow.stories.ts +++ b/code/addons/docs/template/stories/docspage/overflow.stories.ts @@ -2,6 +2,7 @@ import globalThis from 'global'; export default { component: globalThis.Components.Pre, + tags: ['docsPage'], args: { text: 'Demonstrates overflow', style: { width: 2000, height: 500, background: 'hotpink' }, diff --git a/code/addons/docs/template/stories/docspage/override.stories.ts b/code/addons/docs/template/stories/docspage/override.stories.ts index 9b33668b884..b96dde24c07 100644 --- a/code/addons/docs/template/stories/docspage/override.stories.ts +++ b/code/addons/docs/template/stories/docspage/override.stories.ts @@ -15,6 +15,7 @@ const Override = () => 'overridden'; export default { component: globalThis.Components.Button, + tags: ['docsPage'], args: { label: 'Click Me!' }, parameters: { chromatic: { disable: true }, diff --git a/code/addons/docs/template/stories/docspage/source.stories.ts b/code/addons/docs/template/stories/docspage/source.stories.ts index 93260bc1ceb..62eb646c6a0 100644 --- a/code/addons/docs/template/stories/docspage/source.stories.ts +++ b/code/addons/docs/template/stories/docspage/source.stories.ts @@ -2,6 +2,7 @@ import globalThis from 'global'; export default { component: globalThis.Components.Button, + tags: ['docsPage'], args: { label: 'Click Me!' }, parameters: { chromatic: { disable: true } }, }; diff --git a/code/lib/client-api/src/StoryStoreFacade.ts b/code/lib/client-api/src/StoryStoreFacade.ts index 07b14e2d0a8..8b27fdde03d 100644 --- a/code/lib/client-api/src/StoryStoreFacade.ts +++ b/code/lib/client-api/src/StoryStoreFacade.ts @@ -146,7 +146,7 @@ export class StoryStoreFacade { const { default: defaultExport, __namedExportsOrder, ...namedExports } = fileExports; // eslint-disable-next-line prefer-const - let { id: componentId, title } = defaultExport || {}; + let { id: componentId, title, tags: componentTags = [] } = defaultExport || {}; const specifiers = (global.STORIES || []).map( (specifier: Store_NormalizedStoriesSpecifier & { importPathMatcher: string }) => ({ @@ -188,6 +188,30 @@ export class StoryStoreFacade { isExportStory(key, defaultExport) ); + // NOTE: this logic is equivalent to the `extractStories` function of `StoryIndexGenerator` + const docsOptions = (global.DOCS_OPTIONS || {}) as DocsOptions; + if (docsOptions.enabled && storyExports.length) { + // We will use tags soon and this crappy filename test will go away + if ( + fileName.match(/\.mdx$/) || + (docsOptions.docsPage && componentTags.includes('docsPage')) + ) { + const name = docsOptions.defaultName; + const docsId = toId(componentId || title, name); + this.entries[docsId] = { + type: 'docs', + standalone: false, + id: docsId, + title, + name, + importPath: fileName, + componentId, + tags: [...componentTags, 'docs'], + storiesImports: [], + }; + } + } + storyExports.forEach(([key, storyExport]: [string, any]) => { const exportName = storyNameFromExport(key); const id = storyExport.parameters?.__id || toId(componentId || title, exportName); @@ -205,30 +229,9 @@ export class StoryStoreFacade { title, importPath: fileName, componentId, - tags: [...(storyExport.tags || []), ...(defaultExport.tags || []), 'story'], + tags: [...(storyExport.tags || []), ...componentTags, 'story'], }; } }); - - // NOTE: this logic is equivalent to the `extractStories` function of `StoryIndexGenerator` - const docsOptions = (global.DOCS_OPTIONS || {}) as DocsOptions; - if (docsOptions.enabled && storyExports.length) { - // We will use tags soon and this crappy filename test will go away - if (fileName.match(/\.mdx$/) || docsOptions.docsPage) { - const name = docsOptions.defaultName; - const docsId = toId(componentId || title, name); - this.entries[docsId] = { - type: 'docs', - standalone: false, - id: docsId, - title, - name, - importPath: fileName, - componentId, - tags: [...(defaultExport.tags || []), 'docs'], - storiesImports: [], - }; - } - } } }