-
-
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
Addons-links with MDX #10846
Comments
Parent issue #6700 |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
I also ran into this while investigating #11590 - is there a workaround for now? |
I'm not sure if this was ever intended to work.. |
@ndelangen Hmm, it works in the code I'm looking at. Maybe it is because you have text on the same line? Can you try it with the LinkTo on it's own line? |
I didn't check what happens when |
This seems to work: import LinkTo from '@storybook/addon-links/react';
<Meta title="About/Intro" />
# Official-storybook
Welcome to `official-storybook`, a collection of test cases and demos for `@storybook/react` and all its addons.
Should be a link here >>> <LinkTo kind="test" story="index">Go to index</LinkTo> <<< Should be a link here |
Yeah, but if you have a "kind" without a "story", the component throws because of some internals. |
aha |
This is fixed in 6.0.0 I verified using: import LinkTo from '@storybook/addon-links/react';
<Meta title="About/Intro" />
# Official-storybook
Welcome to `official-storybook`, a collection of test cases and demos for `@storybook/react` and all its addons.
Should be a link here >>> <LinkTo kind="Core/Args">Go to index</LinkTo> <<< Should be a link here |
I’m still getting the error. I’m on the freshly released |
Do you have a repro? |
@shilman Thanks for the follow-up! I created a minimal reproduction case: https://github.com/isellsoap/storybook-issue-10846 Visiting the "Introduction" story triggers the error in the browser console. |
Thanks for the repro, hopefully we'll be able to take a look quickly! |
@isellsoap I think it should be |
@shilman I just tried it, using |
I'm also getting the same error, however when I also specify
|
@unematiii True, the errors don’t appear with |
@isellsoap Yeah, it works for me. package.json:
SomeComponent.stories.mdx: import LinkTo from '@storybook/addon-links/react';
Uses <LinkTo kind="base/atoms/misc/Component" story="as-a-tag">Component</LinkTo> to provide corresponding slots. base/atoms/misc/Component/Component.stories.mdx: ## As `a` tag
<Story name="As `a` tag">{Template.bind({})}</Story> |
I think this needs to have Edit: This project would really benefit having |
thanks @unematiii :) Looking at this I got rid of the problem by adding
It's maybe a bit hacky but it works for now. |
@empressmoon Hmm, well it works without errors if you add a |
Hello y'all! I'm still running into this on v6.2.7 and am wondering if there is any timeline on resolution for allowing you to only supply a Thanks! |
This is still an issue on 6.3.4. (As mentioned above) without a |
@devintyler any chance you can create a PR with those changes? |
@unematiii thanks for bringing it to my attention! Will discuss with @tmeasday and figure out the right way forward. 🙏 |
Is there a solution for Vue + MDX? |
Importing the react component worked just fine |
I still cannot get this working in MDX import { linkTo } from '@storybook/addon-links';
import React from 'react';
export class Link extends React.Component {
constructor(props) {
super(props);
this.title = props.title;
this.story = props.story;
this.children = props.children;
}
render() {
let style = { color: 'rgb(30, 167, 253)', textDecoration: 'none', cursor: 'pointer' };
return (
<a style={style} onClick={linkTo(this.title, this.story)}>
{this.children}
</a>
);
}
} Usage in MDX: import { Link } from './mdx';
<Link title="Story Title" story="Story">Go to Story</Link> |
I'm fairly sure this is no longer a problem in Storybook 7.0 beta. If someone could verify this, and report if it's still an issue? |
Hello, I tried to use
addon-links
with MDX (addon-docs
) and I wondered whystory
property ofLinkTo
(fromreact
package) is required? I have several doc pages withoutStory
at all and I want to navigate such pages usingLinkTo
. Btw, it works but annoying error drops in the console.The error comes from
sanitize
method ofstorybookjs/csf
package.hrefTo
method trying to generate url but fails when calling methodtoId
Expected behavior
There are no errors in the console.
Code snippets
The text was updated successfully, but these errors were encountered: