Replies: 1 comment 4 replies
-
Hey @katcaola! I've been trying to do something similar too. Did you find a solution? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Dependecies / Problem Statement
I have a component library that uses Storybook
7.5.1
.Our component folders are set up like this:
Given this structure, it would be nice to be able to be able to import the
readme.md
for every component into each*.stories.ts
.The reason for this is that the
readme.md
gets rendered when looking at the code base (locally or on our server) and has component requirements and other information that is not in the generated autodocs stories. I would like to also make sure this information is available in our stories so that it appears in our hosted storybook instance, which is more accessible to non-technical folks (such as UI/UX, managers, and others who may not have access to our code base).The AutoDocs are also nice because the developers do not have to write the documentation, they just have to fill in parameters, and storybook renders the rest (they have historically been bad at upkeeping documentation 😅). We also have a unit test rule where if you have requirements in the
readme.md
and do not create corresponding unit tests, the build will fail, so this encourages developers to have requirements in thereadme.md
and create unit tests.Thus, it would be nice to use the files we already have and keep the process as auto-generated as possible.
Research
According to the storybook docs, I have found that storybook allows for a custom autodocs page template via a
*.mdx
file.Inside my
.storybook/preview.ts
I have my custom autodoc page:Inside my
CustomDocsPage.mdx
I want to be able to do something like this:I have found that I can do something very similar via a non-template
*.mdx
such asSomeComponent.mdx
with the following content:However, this is not ideal because:
SomeComponent.mdx
) just to display areadme.md
that already exists, and I would need one for every component. I would rather have a globalCustomDocsPage.mdx
that I could change per story.What I've tried and don't understand
I first tried to create a global parameter in my
preview.ts
But that did not work.
I also tried to overwrite it at the story level in my
someComponent.stories.ts
But this didn't work either.
I then wondered if it was a shortcoming of MDX, but after looking at the MDX github discussions, it appears that Storybook and webpack handle
import
s.Thus my questions:
readme.md
path into my AutoDoc template's<Markdown></Markdown>
component?readme.md
content into my AutoDoc template's<Markdown></Markdown>
component?For those also looking to score some internet points, it looks like there is a similar question on Stack Overflow here.
Beta Was this translation helpful? Give feedback.
All reactions