Adding JSON Feed support

· Code

Realizing that JSON has become the de facto goto format for APIs these days, Brent Simmons and Manton Reece recently released the JSON Feed format.

I like this, and when it came out, I added it to my various blogs, including this one. Today, I decided to finally get around to writing about implementing it, so here we are.

Since this blog is running as an express.js app with Ghost as middleware, adding the JSON feed was pretty easy.

I used a variation of the feed2json repo, and added a route for /feed.json.

First, I added the rule to server.js:

Then I created a file called jsonfeed.js:

If you look at line 31, I've hard coded the RSS URL to encode, you can modify this to be passed via ENV variable instead or however you want, but for my purposes, this worked nicely.

Then, in the header of the site I added:

You can view the JSON feed for Coded Geekery here.

This site is using Ghost via middleware so I can add other features to it as well, like the JSON feed, the jobs feed, and a few other backend things I have happening.




About the Author: Roger Stringer

It's all about finding that Work-Life Balance.

I spend most of my time solving problems for people, and otherwise occupying myself with being a dad, cooking, coding, speaking, learning, writing, reading, and the overall pursuit of life.

Learn More
Roger Stringer
  • LinkedIn
  • Reddit
  • Google+
  • Pinterest
  • Pocket
Comments powered by Disqus