Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
64 lines (44 sloc) 2.39 KB
title image thumbnail
An RSS Feed with Hakyll
/images/rss.png
/images/thumbnail-rss.png

Twitter is a really cool social network. I daily use it and I discover a lot of new stuff with it. Unfortunately, it's a company, and they need to earn some money. More and more often, Twitter shows me unwanted content like tweets you could like, accounts to follow or what happens when you're away.

I don't want all these features, I just want the tweets of people I follow in chronological order. What I want is an RSS feed.

RSS, the perfect alternative to Twitter

Add an RSS feed in Hakyll

It's a really simple operation, everything is explained here. In the tutorial, they explain how to render either an Atom or an RSS feed. I decided to provide both. To do that, I've created a small function named createFeed.

createFeed :: Identifier -> RenderingFunction -> Rules ()

Where RenderingFunction is the signature provided by Hakyll for renderAtom and renderRss.

type RenderingFunction = FeedConfiguration
           -> Context String
           -> [Item String]
           -> Compiler (Item String)

Then, my function is just a copy paste from the function in the tutorial.

createFeed name renderingFunction = create [name] $ do
      route idRoute
      compile $ do
          posts <- fmap (take 10) . recentFirst =<<
              loadAllSnapshots "posts/*" "content"
          renderingFunction myFeedConfiguration feedCtx posts

Eventually, I just need to call my new function for renderAtom and renderRss.

createFeed "feed.xml" renderRss
createFeed "atom.xml" renderAtom

The HTML part

To make my feeds work with most of the aggregators, I need to add two links to my default template.

<link rel="alternate" type="application/rss+xml" title="Thibaud Dauce's blog" href="./feed.xml">
<link rel="alternate" type="application/atom+xml" title="Thibaud Dauce's blog" href="./atom.xml">

Which reader

I personally use FreshRSS. It's a simple, self-hostable aggregator under the AGPL license. The installation is really simple and there is a lot of useful features (like keyboard shortcuts and integration with Wallabag)

The clear interface of FreshRSS

You can’t perform that action at this time.