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

Generate markdown from react component #2849

Open
hariria opened this issue Apr 22, 2024 · 0 comments
Open

Generate markdown from react component #2849

hariria opened this issue Apr 22, 2024 · 0 comments

Comments

@hariria
Copy link

hariria commented Apr 22, 2024

Summary

I wanted to ask if there was a way to generate markdown from a React component.

Say for example I wanted to create a custom React component that would return a markdown string for a code snippet. After importing it, I'd like Nextra to then render the code snippet correctly. Is there a way to do such a thing?

Example

React

export function JSXCodeblock({ permalink }: RemoteCodeblockProps) {
  return '```bash filename="Terminal"' + "\nhello" + "```";
}

Markdown

import { JSXCodeblock } from '@components/index'

...

<JSXCodeblock />

Renders...

Screenshot 2024-04-22 at 4 52 32 PM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant