Rory's Diary
Home
Blog
Projects
Facebook
Google+
Github
RSS

RSS Auto-Update

04/14/15

So, something I want to do is auto-update my RSS when I publish a blog post. Really, I want to make a temporary file that gets automatically opened in vim when I try to publish a blogpost. It'll have an init'd RSS item that I can edit to my liking, save, and have that be put in its proper place in my blog RSS file. This would be an experience similar to how I do things with git commits.

I think a good start would be to see if I can feed an rss (aka xml) file into cheerio:

/*jslint node: true */
(function () {
    'use strict';

    var fs = require('fs');

    fs.readFile('public/basic.rss', 'utf-8', function (err, data) {
        var $;
        if (err) {
            return console.log('Basic RSS not found!');
        }

        $ = require('cheerio').load(data);

        console.log($('item').html());
    });
}());

And the output?

$ node scripts/rssUpdate.js

      <title>Site Thinking</title>
      <link>http://www.ksionda.me/blog/site_thinking.html
      <description>
        New post on blog! "Site Thinking" wherein I go through a minimal list
        of things to do to my site before I switch to working on other things.
        I add "automatic RSS updating" when I realized I added this post to
        the RSS, Stephan. It's amazing how often I forget about this file.
      </description>
      <guid>http://www.ksionda.me/blog/site_thinking.html</guid>
   

It works! Yeah! Cheerio, you are a cool, awesome friend.

That'll have to do for now.