Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fixing and Parsing WordPress Rest Api content in React. https://since1979.dev/fixing-and-parsing-wordpress-rest-api-content-in-react/
import React from "react";
import parse from "html-react-parser";
import Gist from "super-react-gist";
export default function WpApiContent(props) {
return parse(props.content, {
replace: (domNode) => {
if(domNode.name === "script" && domNode.attribs.src.indexOf("/gist.github.com/") ) {
return (<Gist url={domNode.attribs.src.replace(".js", "")} />)
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.