Steve Higgs

React in markdown

October 10, 2020

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:

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