DEV Community

Keith Hirst
Keith Hirst

Posted on • Originally published at keithhirst.dev

The Tech Insiders PodQuest: Devlog #2

TLDR

I de-risked parts of my podcasts RSS feed generation by writing an RSS feed for my blog. I used a package called RSS and you can see the result here

Mission

I set out this week to generate an RSS feed for my blog to de-risk some of the assumptions I was making about generating a podcast RSS feed. I assumed:

  • Generation could be automated easily by looping over episodes
  • I would have to write the core part of the RSS feed by hand

Research

It is much easier to find a post about generating an RSS feed for your blog than a Podcast. I found this post by Ashlee M Boyer. It explains how to build an RSS feed better than any other that I saw.

She actually sold me on RSS feeds for a blog. I really questioned how much they were used. RSS feeds seem tedious but, the idea of one place with all the blog articles you care about from around the web actually sounds quite nice!

I also wanted to make this client-side because I wanted the data to be up to date every time someone tries to check. Ashlee's post reminded me of getStaticProps in NextJS. This allows me to generate the feed at build time. This is great because my blog posts are markdown files stored in GitHub. So if I want to publish a blog post, I have to rebuild the site.

This has got me thinking, could I do this for my podcasts also. One less serverless function would be great. I don’t have this planned out in my head yet, but I’m imagining if I have an admin portal on my podcast site to upload a new episode that could trigger a rebuild of the site.

Do we really need a package?

It is always good to weigh the benefits of a package and its many dependencies VS writing it myself. Some packages are great if they save me a lot of time, even if there are lots of dependencies. Some packages offer way more features than I will ever use and are not really worth the extra space they take up.

Ashlee used a package called Feed, and she used this because it encoded HTML. When I checked out her RSS feed I saw that she had her full blog post there. I just want a link back to my site, so adding HTML to my RSS feed isn't a requirement.

But one thing that I didn’t consider was the description. I realised this oversight when I looked at a random podcast feed. It used HTML to format their description for podcast players, which I feel is important.

The Solution

Feed is a really great package, you don't need a ton of documentation to get started for one. But, it doesn’t support custom tags though, which is needed for certain podcast players. I went searching for alternatives and all of the ones I looked at had a dependency on a package named "RSS". When I checked the documentation, the example included the custom tags needed for getting a podcast on iTunes.

Take this following advice with a pinch of salt but, if you look at the weekly downloads you can get an idea of how good a package is. Always do research if in doubt though, packages all have to start somewhere so a few hundred downloads may just mean it isn’t popular yet but is still amazing.

My solution was pretty much the same as Ashlee’s. I just took the 15 most recent posts for my RSS feed. You can see the code below, but I would definitely recommend going and checking out Ashlee’s post to get a better understanding of RSS feeds.

  const feed = new RSS({
    title: 'Web Development blog by Keith Hirst',
    description: 'I am a Software Consultant based in the UK writing articles around the various technical and soft skills that I have learn since I started professional Software engineering in 2011',
    feed_url: `${baseUrl}/rss.xml`,
    site_url: baseUrl,
    language: 'en'
  });

  allPostsData.slice(0,15).forEach(({id, date, title, description }) => (
    feed.item({
      title,
      description,    
      author: 'Keith Hirst',
      url: `${baseUrl}/posts/${id}`,
      date
    }))
  )

  fs.writeFileSync('public/rss.xml', feed.xml());
Enter fullscreen mode Exit fullscreen mode

And that outputs a file to https://keithhirst.dev/rss.xml for people to use in their viewers.

Next Steps

I wasn't that surprised at how easy it was to write an RSS feed, but I was very surprised how much fun it was and also realising the benefits of having an RSS feed on your site has really made me re-think how useful they are.

I'm due to record my first interview in the next couple of weeks and then I can start to build out the hosting for my podcast. After that I can start building out my site and hosting. I am probably going to use AWS because I am familiar with it but I will talk more about my tech choices next time.

See you next time!

Discussion (0)