gatsby
Oct 10, 2020
React within markdown in Gatsby
Getting react running in markdown didn't prove too hard
I wanted to have the ability to inject react into markdown for this blog. Luckily Gatsby has a plugin called MDX that allows just this. You can see the changes needed here and a fix for the rss generator here.
And just to prove it:
Click a button
You clicked 0 times!
Including a component
All this requires is for you to import the component in the markdown file in the same way you would in a js file. Then call the the component as normal:
import Counter from "../../../src/components/counter";
blah blah random markdown
<Counter/>
More random markdown