Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.8k
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Is your feature request related to a problem? Please describe. I would like docs stories to link to their Previous and Next stories at either the top or bottom of the page. I tried searching for variations of "storybook" "addon-docs" "previous next" "link", but wasn't able to find documentation that this feature already exists. Describe the solution you'd like Here is a screenshot from Docusaurus showing the ideal behavior: For Storybook, given a sidebar of
I would like the Guide|Installation docs to include at either/both of the top and bottom of the docs. Describe alternatives you've considered Storybook supports linking to stories, so I could manually include the previous and next buttons for each docs story. However, this is manual and prone to becoming outdated. Ideally we would look at the storybook stories context, but I don't know enough about storybook's internals to know how to do this. Are you able to assist bring the feature to reality? Yes, if you can point me to the relevant code. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 6
Replies: 7 comments
-
Hi@folz this would be an awesome example of a fairly simple docblock to write. I'm on the hook for documenting |
BetaWas this translation helpful?Give feedback.
All reactions
-
For sure, that sounds good to me! Is there a place I can follow for updates to 6.0, or would you be able to tag me in this issue once that's released? |
BetaWas this translation helpful?Give feedback.
All reactions
-
@folz absolutely. i'll tag you here when it's ready. in terms of 6.0 here's a general issue (still basically empty):#9311 and for doc blocks documentation there isn't an issue yet. here's the closest thing to track#8379 |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
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! |
BetaWas this translation helpful?Give feedback.
All reactions
-
Converting this to a discussion. We’re reserving feature issues for things that are on ourshort-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! |
BetaWas this translation helpful?Give feedback.
All reactions
-
This would be an excellent feature to add. We have implemented it in our codebase in a hacky way but a proper official DocBlock for it would be great. |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Until we get a proper block for this basic feature, here's a block you can place in your MDX files. Might have to tweak it some for your setup or Storybook version (I'm on version 8). Tried using exportconstFooter=({ nextLink, prevLink, nextLinkText, prevLinkText}:{nextLink:string;prevLink:string;nextLinkText:string;prevLinkText:string;})=>{varfindAdjacentSibling=function(elem,selector,direction:'prev'|'next'){// Get the next sibling elementvarsibling=elem[direction==='prev' ?'previousElementSibling' :'nextElementSibling'];if(!selector)returnsibling;while(sibling){if(sibling.matches(selector))returnsibling;sibling=sibling[direction==='prev' ?'previousElementSibling' :'nextElementSibling'];}};constgetAdjacentPageInSidebar=(direction:'prev'|'next')=>{// From parent iframeconstsidebar=window.parent.document.querySelector('#storybook-explorer-tree');if(!sidebar)returnnull;constsidebarActiveItem=sidebar.querySelector('[data-selected="true"]');if(!sidebarActiveItem)returnnull;constsidebarAdjacentToActiveItem=findAdjacentSibling(sidebarActiveItem,'.sidebar-item',direction);if(!sidebarAdjacentToActiveItem)returnnull;constsidebarAdjacentToActiveItemLink=sidebarAdjacentToActiveItem.querySelector('a');if(!sidebarAdjacentToActiveItemLink)returnnull;console.log(sidebarAdjacentToActiveItemLink.getAttribute('href'));returnsidebarAdjacentToActiveItemLink;};constprevDocLink=getAdjacentPageInSidebar('prev');constnextDocLink=getAdjacentPageInSidebar('next');constprevDocLinkText=prevDocLink?.textContent;constnextDocLinkText=nextDocLink?.textContent;constprevDocLinkHref=prevDocLink?.getAttribute('href');constnextDocLinkHref=nextDocLink?.getAttribute('href');return(<>{(prevLink||prevDocLinkHref)&&(<ahref={prevLink??prevDocLinkHref}>{prevLinkText||prevDocLinkText}</a>)}{(nextLink||nextDocLinkHref)&&(<ahref={nextLink??nextDocLinkHref}>{nextLinkText||nextDocLinkText}</a>)}</>);}; Then at the bottom of your MDX you would do |
BetaWas this translation helpful?Give feedback.
All reactions
This discussion was converted from issue #9676 on June 14, 2023 02:53.
