Hello! New to using Gatsby and I'm trying to render HTML tags from a frontmatter field in a post template. I need a short paragraph of text with breaks in it separate to the main body of content from my Markdown file. I'm used to doing this with Hugo using it's safeHTML function. Is there a way I can do it in Gatsby?
I'm using the remark plugin to pull in my frontmatter fields. But it's just pulling in the text as a string, as expected.
Thanks!
You can use react's dangerouslySetInnerHTML (as a contrast to safeHTML i guess :) ):
<div dangerouslySetInnerHTML={{__html: post.frontmatter.fieldWithHtml }} />
Doh. Of course that works! Thanks very much :)
Most helpful comment
You can use react's
dangerouslySetInnerHTML(as a contrast to safeHTML i guess :) ):