A step-by-step tutorial on how to implement an RSS feed from JSON by converting it to XML and creating a static page in Gatsby π
Photo by Cookie the Pom on Unsplash
I
mplementing a site-wide RSS feed in Gatsby can be done very easily. I can recommend implementing the official Gatsby feed plugin.
In this tutorial, I want to show you how you can implement an RSS feed for a specific URL or page. In my case, the data for the RSS feed was provided to me via a REST API endpoint that returned JSON.
π‘This tutorial assumes you already have a Gatsby site setup and running. If you are new to Gatsby, I can highly recommend the Gatsby docs to get started.
Here are the steps that I am going to walk you through in detail in this tutorial:
β Test your API endpoint with
Postman
β Call JSON in /gatsby-node.js with
Axios
β Shape JSON by turning it into a JavaScript Object
β Convert the new object to RSS XML with
jstoxml
β Use fs from Node.js to create a new file rss.xml
β Test your new RSS feed with an RSS validator
Without further ado, letβs get started π
It is as easy as creating a new βGETβ Request and inserting the endpoint. If your endpoint requires authentication you can read more about how to authenticate in Postman in the Postman Learning Center.
#nodejs #api #rss #xml #json