I was using the rich text component , it’s awesome but I was wondering if I could render anything else than plain html with it. I would like to render directly a React Component and not only its html output.
We could probably fork your @contentful/rich-text-html-renderer to render custom react component instead of html. Do you have any recommandation ?
My use case is that if I want to render a complex React component with a state, some logic inside it, it will not work properly with your default render method since you are expecting a pure HTML string as a return. I would like to use contentful to have a set of component available and to build my custom template/landing page with it.
So just to summarize, I would like to render my own React Component instead of static html, do you have a library for that or should we build our own tree parser ?
Plus, is it possible to make @contentful/rich-text-html-renderer public on github ?
Hello, I’d just like to +1 this thread. We are currently investigating how to use a richtext embedded entry to display a node queried from the graphql API.
const { richTextFromMarkdown } = require("@contentful/rich-text-from-markdown");
const markdownStr = `
1. Rends-toi sur le <a href="https://www.infogreffe.fr" rel="nofollow noopener" title="Infogreffe">site Infogreffe </a>, le site officiel qui référence toutes les entreprises françaises.
2. Une fois sur le site, clique sur "recherche avancée", à droite de la barre de recherche.`;
console.log(JSON.stringify(richTextFromMarkdown(markdownStr)));
I’ve just checked with my colleague that wrote this demo and unfortunately, at this moment, it doesn’t yet have an implementation for lists. It indeed was just a bit of code to demonstrate our concepts, but it’s surely not fully ready for being used in a production environment. If you were able to implement this in your side, the key here would be to adjust the render-item.js file.
Hi @gabriel, if you are talking of the Rich Text content to React component question. I actually did it, see #3.
Thanks for your demo.
The issue now is with the migration tool rich-text-from-markdown, on the readme, there is a mention indicating you are supporting the list el but in fact nop :/.
Could you add me as a contributor of this repo ? The rich text feature is really powerful but if we are not able to convert our existing content to this content type, it’s kind of a pain in the ass.
The sandbox demo seems to be broken. Is there somewhere else I can find examples? I’m trying to render a custom React component inside the documentToHtmlString's options, but it seems to convert it into a string =.=