Skip to content
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

[Feature Request][v7]: Allow rendering custom Markdown just as in v6 #20586

Closed
wintercounter opened this issue Jan 12, 2023 · 6 comments · Fixed by #20796
Closed

[Feature Request][v7]: Allow rendering custom Markdown just as in v6 #20586

wintercounter opened this issue Jan 12, 2023 · 6 comments · Fixed by #20796

Comments

@wintercounter
Copy link

wintercounter commented Jan 12, 2023

Is your feature request related to a problem? Please describe

In v7 when I use the Description block in a standalone Docs MDX file, it immediately want to have a CRF file. Until now we could use Description to render custom markdown in without a stories file, now I cannot do that. We were rendering our Readme.md as our Introduction page.

import { Meta, Description } from '@storybook/blocks';
import Readme from '../README.md';

<Meta title="Introduction" />

<Description>{Readme}</Description>

Describe the solution you'd like

A Markdown component maybe? I simple re-export of https://github.com/storybookjs/storybook/blob/next/code/ui/blocks/src/components/Description.tsx called Markdown inside blocks.

import { Meta, Markdown } from '@storybook/blocks';
import Readme from '../README.md';

<Meta title="Introduction" />

<Markdown>{Readme}</Markdown>

Describe alternatives you've considered

No response

Are you able to assist to bring the feature to reality?

yes

Additional context

No response

@wintercounter wintercounter changed the title [Feature Request][v7]: Allow rendering custom Markdown [Feature Request][v7]: Allow rendering custom Markdown just as in v6 Jan 12, 2023
@shilman
Copy link
Member

shilman commented Jan 17, 2023

@JReinhold WDYT?

@JReinhold
Copy link
Contributor

Importing plain md files into docs is definitely a use case.
It was a deliberate decision to pull that out of the Description block to shrink it's surface are to more core features.

I would think that you could import .md files directly in MDX and just render it as components

import Readme from '../README.md';

<Readme />

What's required to make that work @shilman?

If we can't make that work I would agree with @wintercounter that a <Markdown /> block is valuable.

@wintercounter
Copy link
Author

The problem with that would be that not everyone want's to use it as a React component, or they want to to some pre-processing on the string. For example in my case when I'm loading the main Readme.md of the repo, I might want to strip out the licences part.

This would also be a breaking change for those who import it as string already.

@JReinhold
Copy link
Contributor

The problem with that would be that not everyone want's to use it as a React component, or they want to to some pre-processing on the string. For example in my case when I'm loading the main Readme.md of the repo, I might want to strip out the licences part.

So you mean that you import the md file, and then process it, and then pass the processed string to Description?

This would also be a breaking change for those who import it as string already.

The Description component is only deprecating the support of markdown children, not removing it entirely (unless something is wrong though!), so it's not a breaking change until 8.0, giving plenty of time to come up with alternatives.

@shilman shilman moved this to Required for QA in Core Team Projects Jan 23, 2023
@JReinhold JReinhold moved this from Required for QA to In Progress in Core Team Projects Jan 24, 2023
@wintercounter
Copy link
Author

I opened this ticket after trying out v7 beta and passing Markdown directly is Description is not working there anymore, I had to recreate my own component to make it work.

@github-project-automation github-project-automation bot moved this from In Progress to Done in Core Team Projects Jan 27, 2023
@shilman
Copy link
Member

shilman commented Jan 28, 2023

Son of a gun!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-beta.36 containing PR #20796 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb@next upgrade --prerelease

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants