Add a way to declare redirects #23093
Replies: 3 comments
-
Converting this to a discussion. We’re reserving feature issues for things that are on our short-term roadmap. We’ll check back periodically to see whether this is a good candidate to be added. If this feature would be useful to you, please upvote! |
Beta Was this translation helpful? Give feedback.
-
I think its an awesome suggestion. For anyone looking for a way to do it now (which I feel is a bit hacky but functions). I added in the
|
Beta Was this translation helpful? Give feedback.
-
You can add additional routes and/or redirects via // .storybook/middleware.js
const expressMiddleWare = (router) => {
router.get('/favicon.svg', (req, res) => {
res.redirect('/static/img/my-icon.svg');
});
};
module.exports = expressMiddleWare; |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe
I want to move a story from
A/MyComponent
toB/MyComponent
to better organize my storybook. However, this would mean that links to?path=/docs/a-mycomponent
would no longer take users to theMyComponent
story. I want to preserve compatibility with those links.Describe the solution you'd like
I'd like to be able to declare redirects, perhaps as entries in the Storybook config:
Describe alternatives you've considered
I tried declaring a story with the same
title
as the old one that returns alinkTo
the new one:This works, but it results in an extra entry being added to the sidebar/search: The sidebar shows both
A/MyComponent
andB/MyComponent
. And apart from the sidebar issue (which could be addressed by #9209), it's a lot of code for a simple redirect.Are you able to assist to bring the feature to reality?
Yes, I'd be happy to work on this as either a feature in Storybook proper (part of
@storybook/router
?) or as an addon. (The storybook-redirect addon is made for a different purpose.) I could use some pointers on how the router works, though.Beta Was this translation helpful? Give feedback.
All reactions