Home

Awesome

rss Build Status rss

RSS feed generator. Add RSS feeds to any project. Supports enclosures and GeoRSS.

Usage

Create a new feed

var RSS = require('rss');

var feed = new RSS(feedOptions);
feedOptions

Add items to a feed

An item can be used for a blog entry, project update, log entry, etc. Your RSS feed can have any number of items. Most feeds use 20 or fewer items.

feed.item(itemOptions);
itemOptions
Feed XML
var xml = feed.xml({indent: true});

This returns the XML as a string.

indent optional boolean or string What to use as a tab. Defaults to no tabs (compressed). For example you can use '\t' for tab character, or ' ' for two-space tabs. If you set it to true it will use four spaces.

Example Usage

var RSS = require('rss');

/* lets create an rss feed */
var feed = new RSS({
    title: 'title',
    description: 'description',
    feed_url: 'http://example.com/rss.xml',
    site_url: 'http://example.com',
    image_url: 'http://example.com/icon.png',
    docs: 'http://example.com/rss/docs.html',
    managingEditor: 'Dylan Greene',
    webMaster: 'Dylan Greene',
    copyright: '2013 Dylan Greene',
    language: 'en',
    categories: ['Category 1','Category 2','Category 3'],
    pubDate: 'May 20, 2012 04:00:00 GMT',
    ttl: '60',
    custom_namespaces: {
      'itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd'
    },
    custom_elements: [
      {'itunes:subtitle': 'A show about everything'},
      {'itunes:author': 'John Doe'},
      {'itunes:summary': 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store'},
      {'itunes:owner': [
        {'itunes:name': 'John Doe'},
        {'itunes:email': 'john.doe@example.com'}
      ]},
      {'itunes:image': {
        _attr: {
          href: 'http://example.com/podcasts/everything/AllAboutEverything.jpg'
        }
      }},
      {'itunes:category': [
        {_attr: {
          text: 'Technology'
        }},
        {'itunes:category': {
          _attr: {
            text: 'Gadgets'
          }
        }}
      ]}
    ]
});

/* loop over data and add to feed */
feed.item({
    title:  'item title',
    description: 'use this for the content. It can include html.',
    url: 'http://example.com/article4?this&that', // link to the item
    guid: '1123', // optional - defaults to url
    categories: ['Category 1','Category 2','Category 3','Category 4'], // optional - array of item categories
    author: 'Guest Author', // optional - defaults to feed author property
    date: 'May 27, 2012', // any format that js Date can parse.
    lat: 33.417974, //optional latitude field for GeoRSS
    long: -111.933231, //optional longitude field for GeoRSS
    enclosure: {url:'...', file:'path-to-file'}, // optional enclosure
    custom_elements: [
      {'itunes:author': 'John Doe'},
      {'itunes:subtitle': 'A short primer on table spices'},
      {'itunes:image': {
        _attr: {
          href: 'http://example.com/podcasts/everything/AllAboutEverything/Episode1.jpg'
        }
      }},
      {'itunes:duration': '7:04'}
    ]
});

// cache the xml to send to clients
var xml = feed.xml();

Notes

Inspiration

I started this module years ago (April 2011) because there weren't any Node modules for creating RSS. Nearly 50 modules use RSS, as well as many web sites and the popular Ghost publishing platform.

Contributing

Contributions to the project are welcome. Feel free to fork and improve. I do my best accept pull requests in a timely manor, especially when tests and updated docs are included.

About the Author

Hi! Thanks for checking out this project! My name is Dylan Greene. When not overwhelmed with my two young kids I enjoy contributing to the open source community. I'm also a tech lead at Opower. @dylang @dylang

Here's some of my other Node projects:

NameDescriptionnpm Downloads
npm‑checkCheck for outdated, incorrect, and unused dependencies.npm-check
grunt‑notifyAutomatic desktop notifications for Grunt errors and warnings. Supports OS X, Windows, Linux.grunt-notify
shortidAmazingly short non-sequential url-friendly unique id generator.shortid
grunt‑promptInteractive prompt for your Grunt config using console checkboxes, text input with filtering, password fields.grunt-prompt
xmlFast and simple xml generator. Supports attributes, CDATA, etc. Includes tests and examples.xml
changelogCommand line tool (and Node module) that generates a changelog in color output, markdown, or json for modules in npmjs.org's registry as well as any public github.com repo.changelog
space‑hogsDiscover surprisingly large directories from the command line.space-hogs
observatoryBeautiful UI for showing tasks running on the command line.observatory
captionbotGet captions for image using Microsoft's CaptionBot 🤖captionbot
grunt‑attentionDisplay attention-grabbing messages in the terminalgrunt-attention
what‑dogGet the breed of a dog from an image using Microsoft's what-dog.what-dog
anthologyModule information and stats for any @npmjs useranthology
random‑puppyGet a random imgur image url, by default a puppy.random-puppy
grunt‑catEcho a file to the terminal. Works with text, figlets, ascii art, and full-color ansi.grunt-cat

This list was generated using anthology.

License

Copyright (c) 2017 Dylan Greene, contributors.

Released under the MIT license.

Screenshots are CC BY-SA (Attribution-ShareAlike).


Generated using grunt-readme with grunt-templates-dylang on Wednesday, January 11, 2017. _To make changes to this document look in /templates/readme/