Last active
April 15, 2024 10:45
-
-
Save vanaf1979/c6d5628b4fc96946f6c95f3e79628d57 to your computer and use it in GitHub Desktop.
Fixing and Parsing WordPress Rest Api content in React. https://since1979.dev/fixing-and-parsing-wordpress-rest-api-content-in-react/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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