How to pass in Markdown file as argument? #1252
-
Hello, I am following this link to understand how to use this library. In this code: import React from 'react'
import ReactDOM from 'react-dom'
import Markdown from 'react-markdown'
import rehypeHighlight from 'rehype-highlight'
const markdown = `
# Your markdown here
`
ReactDOM.render(
<Markdown rehypePlugins={[rehypeHighlight]}>{markdown}</Markdown>,
document.querySelector('#content')
) Instead of the string representing the markdown, is there a way I can pass a markdown file I have somewhere else (not necessarily in the same directory) instead? This would be very useful. Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
remcohaszing
Oct 27, 2023
Replies: 1 comment 7 replies
-
How to do files is unrelated to this project and relates to what other tools you have. You can use |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adding onto @ChristianMurphy’s answer, I recommend using Vite and MDX. It’s the closest to what you have currently.
The only configuration you need is:
That should allow you to import and render your markdown file like this.