Open tobiasdiez opened 2 months ago
Disclaimer This information might be inaccurate, due to it being generated automatically
To address the issue where the story indexer doesn't support type: docs
, follow these steps:
Update extractStories
Method:
Modify the extractStories
method in StoryIndexGenerator.ts
to correctly handle entries with type: docs
.
const entries: ((StoryIndexEntryWithExtra | DocsCacheEntry) & { tags: Tag[] })[] = indexInputs.map((input) => {
const name = input.name ?? storyNameFromExport(input.exportName);
const componentPath = input.rawComponentPath && this.resolveComponentPath(input.rawComponentPath, absolutePath, matchPath);
const title = input.title ?? defaultMakeTitle();
const id = input.__id ?? toId(input.metaId ?? title, storyNameFromExport(input.exportName));
const tags = combineTags(...projectTags, ...(input.tags ?? []));
return {
type: input.type || 'story', // Ensure type is correctly set
id,
extra: {
metaId: input.metaId,
stats: input.__stats ?? {},
},
name,
title,
importPath,
componentPath,
tags,
};
});
Update Tests:
Ensure that the tests in StoryIndexGenerator.test.ts
cover scenarios where type: docs
is returned by the indexer.
it('handles entries with type: docs correctly', async () => {
const specifier: NormalizedStoriesSpecifier = normalizeStoriesEntry('./src/docs/*.mdx', options);
const generator = new StoryIndexGenerator([specifier], autodocsOptions);
await generator.initialize();
const { storyIndex } = await generator.getIndexAndStats();
expect(storyIndex.entries['docs-entry-id'].type).toBe('docs');
});
/.github/DISCUSSION_TEMPLATE/help.yml /.github/DISCUSSION_TEMPLATE/ideas.yml /.github/comments/invalid-link.md /code/core/src/core-server/utils/summarizeIndex.test.ts /code/core/src/preview-errors.ts /code/addons/docs/angular /test-storybooks/ember-cli/ember-output/storybook-docgen /.github/comments /.github/DISCUSSION_TEMPLATE/rfc.yml /docs/_snippets/test-runner-with-index-json.md /code/core/src/core-server/utils/StoryIndexGenerator.test.ts /code/addons/docs/ember /docs/_snippets/test-runner-no-index-json.md /code/core/src/core-server/utils/mockdata/errors/NoMeta.stories.ts /docs/_snippets/main-config-indexers-jsonstories.md /docs/_snippets/storybook-preview-with-angular-polyfills.md /code/lib/cli-storybook/project.json /code/frameworks/ember/src/client/preview/docs /code/lib/cli/src/automigrate/fixes/mdx-gfm.ts /code/addons/docs/template/stories/docspage /code/core/src/csf-tools/CsfFile.test.ts /code/addons/storysource /code/core/src/server-errors.ts /code/addons/docs/react /code/core/src/csf-tools/ConfigFile.test.ts
Unfortunately we never managed to implement that part of the indexer, which is also why it's still experimental. Thanks for opening this.
Describe the bug
If a story indexer returns
type: docs
, then this is ignored and it is added astype: story
, see https://github.com/storybookjs/storybook/blob/b94ead30bd1798648bc674bce61ba841508b6bbc/code/core/src/core-server/utils/StoryIndexGenerator.ts#L369Reproduction link
https://github.com/tobiasdiez/storybook-vue-addon/pull/118 (see code)
Reproduction steps
No response
System
Additional context
No response