rss(2/0)
Get published today feed
This JavaScript snippet reads multiple RSS/XML feeds on my site and adds a list of the items published on this day to the bottom of my page. I may use this in future to add a “Published On This Day” feed to my site, kind of like how OneDrive will pop up a picture from last year. const parser = new DOMParser(); const today = new Date(); const lastYear = new Date(today.…
Verify your RSS feed
If you have an RSS feed, you can use this snippet as a starting place to review the output. I’m printing the titles of each RSS item to the console, but go as deep as necessary to ensure the right information ends up in your feed. fetch('https://my-url-here.com') .then(res => res.text()) .then(text => { const domParser = new DOMParser(); const doc = domParser.parseFromString(text, 'text/html'); var feedURL = doc.querySelector('link[type="application/rss+xml"]'); return fetch(feedURL.href); }) .…