storybookjs / addon-svelte-csf

[Incubation] CSF using Svelte components.
MIT License
103 stars 32 forks source link

[Bug] `titlePrefix` in advanced story specifiers causes the story to crash with "Didn't find 'xyz' in CSF file" #130

Closed JReinhold closed 1 year ago

JReinhold commented 1 year ago

Describe the bug

Originally discussed at #120.

If a stories specifier uses the advanced pattern with a title prefix like this:

const config = {
  stories: [
    {
      directory: '../src',
      titlePrefix: 'Custom', // πŸ‘ˆ Configure the title prefix
    },
  ],
};

The story will fail to render with "Didn't find 'some-story-id' in CSF file", if it's been written using Svelte CSF.

This happens because the indexer in this addon ignores that title prefix when generating story IDs, but the Storybook CSF processing in the browser does not ignore that title prefix, so the ID it is looking for will not match the IDs in the index.

Steps to reproduce the behavior

Reproduction: https://github.com/mcmxcdev/storybookjs-addon-svelte-csf-120

Screenshots and/or logs

image

Additional context

This bug can probably be fixed by using the makeTitle function that is passed in the indexer options (second parameter) to the indexer function. That function can be used to generate titles automatically, also taking into account any user title specified.

Using makeTitle to fix this bug will likely also solve #129 .

j3rem1e commented 1 year ago

Should be fixed with #134

mcmxcdev commented 1 year ago

Should be fixed with #134

That would be amazing, I have already cloned the project and was thinking of fixing it myself! :tada:

shilman commented 1 year ago

:rocket: Issue was released in v4.0.2 :rocket: