Skip to content

Commit

Permalink
Don't append title prefix to Meta of= docs entries
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeasday committed Jul 6, 2022
1 parent 099c724 commit 256c738
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions lib/core-server/src/utils/StoryIndexGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,33 @@ describe('StoryIndexGenerator', () => {
`);
});

it('does not append title prefix if meta references a CSF file', async () => {
const generator = new StoryIndexGenerator(
[
storiesSpecifier,
normalizeStoriesEntry(
{ directory: './src/docs2', files: '**/*.mdx', titlePrefix: 'titlePrefix' },
options
),
],
options
);
await generator.initialize();

// NOTE: `toMatchInlineSnapshot` on objects sorts the keys, but in actuality, they are
// not sorted by default.
expect(Object.values((await generator.getIndex()).entries).map((e) => e.title))
.toMatchInlineSnapshot(`
Array [
"A",
"A",
"titlePrefix/NoTitle",
"A",
"titlePrefix/docs2/Yabbadabbadooo",
]
`);
});

it('generates no docs entries when docs are disabled', async () => {
const generator = new StoryIndexGenerator([storiesSpecifier, docsSpecifier], {
...options,
Expand Down
2 changes: 1 addition & 1 deletion lib/core-server/src/utils/StoryIndexGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export class StoryIndexGenerator {
dep.dependents.push(absolutePath);
});

const title = userOrAutoTitleFromSpecifier(importPath, specifier, result.title || ofTitle);
const title = ofTitle || userOrAutoTitleFromSpecifier(importPath, specifier, result.title);
const name = result.name || this.options.docs.defaultName;
const id = toId(title, name);

Expand Down

0 comments on commit 256c738

Please sign in to comment.