I'm trying to apply my own style to blog posts I'm obtaining through a rss feed in React. Currently I'm using rss-parser to obtain the content, and I'm using the dangerouslySetInnerHTML prop to display it.
Getting content:
function Blog(props) {
const [feed, setFeed] = useState(null)
let blogID = 0;
let feedName = 'https://roco.org/feed/'
useEffect(() => {
const fetchData = async () => {
let test = await parser.parseURL(CORS_PROXY + feedName);
setFeed(test)
console.log("test", test)
};
fetchData()
}, []);
let title = ""
let content = ""
let date = ""
let finalContent = []
let parsedContent = []
if(feed) {
title = feed.items[blogID].title
content = feed.items[blogID]["content:encoded"]
let isoDate = feed.items[blogID].pubDate
let convDate = new Date(isoDate)
date = convDate.getFullYear()+'-' + (convDate.getMonth()+1) + '-'+convDate.getDate()
}
Displaying content:
<div className= "Blog-content" dangerouslySetInnerHTML={{__html: content}}>
</div>
However, the styling of the components of the blog post often override my own. For example, images included in the blog like this one don't resize properly:
<div style=\"width: 1034px\" class=\"wp-caption aligncenter\"><a href=\"https://www.houstonpress.com/arts/roco-gets-well-deserved-grammy-nod-for-first-album-visions-take-flight-11391485\"><img src=\"https://roco.org/wp-content/uploads/2019/12/roco_river_oaks_chamber_orchestra_concert_photo_02_credit_joel_luks.jpg\" alt=\"ROCO in concert at The Church of St. John the Divine. \" width=\"1024\" height=\"683\" /></a>
Is there a way I can override the styling without writing my own html parser?