Khaledgarbaya / ama

Ask me anything!
https://github.com/Khaledgarbaya/ama/issues?q=is%3Aissue+is%3Aclosed
4 stars 0 forks source link

Displaying Rich Text from Contentful in Gatsby #4

Closed mimbimbo closed 4 years ago

mimbimbo commented 4 years ago

Hi there - Here's my question: How do I properly display Rich Text in Gatsby? I'm able to pull the Rich Text from Contentful with my specific query (for example: allContentfulBlogPost { edges { node { childContentfulBlogPostBodyRichTextNode { json } } } }

However, when I try to display this in my Gatsby page, none of the formatting is there. I was using this to grab the content import { documentToReactComponents } from "@contentful/rich-text-react-renderer" and then:

<div>{documentToReactComponents(props.data.allContentfulBlogPost.edges[1].node.childContentfulBlogPostBodyRichTextNode.json)}</div>

Khaledgarbaya commented 4 years ago

Hi @mimbimbo, Here your video answer https://youtu.be/vKIyhp3PvWw Here is the repo with all the code https://github.com/Khaledgarbaya/rich-text-gatsby

Cheers, Khaled

muhzulzidan commented 3 years ago

right now it is not JSON, but it uses raw, I am having problems with references... can you look at It ?