question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[addon-docs] Link to another story

See original GitHub issue

Is your feature request related to a problem? Please describe. Well of course. I need to link to another story to sort of build a “See also” or “For more information, see…” section.

Describe the solution you’d like I would like to be able to just link to another story by writing a MD link, something like:

See [this cool component](Components|General/CoolComponent) for more information

Storybook would recognize that this is not a regular url, but a link to a story, and transform the link in such a way that it will navigate to that story, instead of trying to open the url as-is.

Describe alternatives you’ve considered The best workaround at the moment would be to go to that story using the existing navigation, recording what the url is, and pasting that into the MD link. It doesn’t feel like that’s the most stable way to go, because I don’t think those url’s a completely chained to the components that are on them.

Are you able to assist bring the feature to reality? Not sure I can, sorry.

Additional context It might be worth noting that the documentation of MDX stories is a bit “all over the place”. I feel there isn’t a single source of truth when it comes to MDX. All I can find is a couple of use-cases (although very common ones) and their solutions, but not an exhaustive reference. Perhaps working on that may reveal that the feature being requested here, is already possible in some other way, that I have no way of being aware of.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:24
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
Bamblehorsecommented, May 22, 2020

LinkTo works nicely 🙂 did some more digging and found a new PR

Seems like since this issue was created you can potentially more reliably use a normal md link like this: [link to another story](/?path=/docs/addons-docs-docs-only--page#bottom)

https://github.com/storybookjs/storybook/pull/9051/files#diff-809d0afec1adb3c90fb654474a0bf015

10reactions
grgurcommented, Jan 16, 2020

I just used @robbeman’s suggestion (thanks!) to navigate to another page with the <LinkTo> component. The router maintains scroll position (doesn’t scroll back to the top) but using anchor links actually worked. Here’s what I did:

import LinkTo from '@storybook/addon-links/react';

Please read the section on <LinkTo kind="writing-docs--page#writing-documentation-stories">Writing Documentation Stories</LinkTo>

Notes:

  • writing-docs - the ID of the other page
  • Appending --page was needed to navigate to another Docs page, although I don’t like that it’s hacky
  • #writing-documentation-stories is the anchor to the h1 tag at the top of another page

I hope that helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Links Addon | Storybook: Frontend workshop for UI development
Link stories together to build demos and prototypes with your UI components. ... The Storybook Links addon can be used to create links...
Read more >
Addon / Links - button with link to another story ⋅ Storybook
Addon. Background · Centered · Actions · Docs · Jest · Knobs. Links. button with link to another story. Custom. Welcome · Button....
Read more >
@storybook/addon-links - npm
Link stories together to build demos and prototypes with your UI ... are 472 other projects in the npm registry using @storybook/addon-links.
Read more >
@storybook/addon-docs | Yarn - Package Manager
how to introduce significant new features (e.g. vue support, story hierarchy)?; how to converge on key design decisions (e.g. new addons API)?; how...
Read more >
storybook/addon-links examples - CodeSandbox
Learn how to use @storybook/addon-links by viewing and forking @storybook/addon-links example apps on CodeSandbox.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found