-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Output JSON list of stories for 3rd party integration #9221
Comments
@JohnAlbin - I made a quick addon https://github.com/atanasster/storybook-addon-export-stories It adds a save to json button to the toolbar. You can play with it - basically you can also save automatically from the setStories event but it can create some complications. Feel free to open issues or send a PR. |
I think wanting a list of stories in a JSON endpoint is a reasonable request, although it increases our surface area slightly. WDYT @ndelangen @tmeasday |
It's a strong yes, we should be able to do this as a webpack plugin also, so that we indeed can generate the .json for serving it and outputting a static file. |
This is on my todo list for this year |
Look what I found! Looks interesting indeed Plugin which generates tests for storybook, using webpack. https://github.com/yandex/storytests-webpack-plugin/blob/master/index.js example: https://github.com/baushonok/tested-storybook |
In 6.0.0 the storybook CLI will have a command:
Which will generate a stories.json storybook/lib/cli/src/generate.js Lines 70 to 79 in 4a3d161
|
Hi @ndelangen . Any news? Version 6 seems to be in RC now |
Tried running the mentioned Command:
|
@atanasster @alexbchr but what's the point to extract them to json, how can you use them after that? I actually wonder if there a way to do the opposite, have stories that are stored in json to be imported into storybook? |
The primary use case of this is for composition:
If your published Storybook includes a If you upload to Chromatic (and in future other services) this all happens automatically. Can you tell me a little more about the use case of generating stories from a JSON file? |
@tmeasday I'm looking to have stories auto-generated and thought something like JSON would be a great common format that can be converted to anything else (if required). But just not sure if it is already supoprted internally or if I need to write something like custom webpack loader and convert them manually to something like JSX (that'd suck) |
Not currently something that's supported but it is something that fits naturally with the args concept. You could do it right now with a loader as you suggest and I'd hazard a guess it wouldn't be too hard if you knew about that kind of thing (we'd be super interested in the result too). Longer term I could see a feature like this landing in the medium term, probably by 7.0 at the latest (don't hold me to that 😉) |
I'm using Edit: upon further inspection, my issue is definitely a manifestation of #11892 |
Is your feature request related to a problem? Please describe.
I was looking to use the list of stories in a 3rd party tool. Unfortunately, I don't see any documented way to get the stories list.
This issue has been brought up before, but closed before implemented:
Describe the solution you'd like
A URL in the Storybook site like
/stories.json
that includes a list of all the stories on the site. Maybe the same information that is available from the storySort function.Describe alternatives you've considered
Scraping the navbar of the Storybook.
Are you able to assist bring the feature to reality?
If I can figure it out, yes.
The text was updated successfully, but these errors were encountered: