Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

feed

jpmonette1.5mMIT4.2.2TypeScript support: included

Feed is a RSS, Atom and JSON feed generator for Node.js, making content syndication simple and intuitive!

rss, atom, feed, syndication, xml, wrapper, blog

readme

Feed for Node.js
Build Status Coverage Status npm version Tested with Jest License: MIT

jpmonette/feed - RSS 2.0, JSON Feed 1.0, and Atom 1.0 generator for Node.js
Making content syndication simple and intuitive!


👩🏻‍💻 Developer Ready: Quickly generate syndication feeds for your Website.

💪🏼 Strongly Typed: Developed using TypeScript / type-safe.

🔒 Tested: Tests & snapshot for each syndication format to avoid regressions.

Getting Started

Installation

$ yarn add feed

Example

import { Feed } from "feed";

const feed = new Feed({
  title: "Feed Title",
  description: "This is my personal feed!",
  id: "http://example.com/",
  link: "http://example.com/",
  language: "en", // optional, used only in RSS 2.0, possible values: http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
  image: "http://example.com/image.png",
  favicon: "http://example.com/favicon.ico",
  copyright: "All rights reserved 2013, John Doe",
  updated: new Date(2013, 6, 14), // optional, default = today
  generator: "awesome", // optional, default = 'Feed for Node.js'
  feedLinks: {
    json: "https://example.com/json",
    atom: "https://example.com/atom"
  },
  author: {
    name: "John Doe",
    email: "johndoe@example.com",
    link: "https://example.com/johndoe"
  }
});

posts.forEach(post => {
  feed.addItem({
    title: post.title,
    id: post.url,
    link: post.url,
    description: post.description,
    content: post.content,
    author: [
      {
        name: "Jane Doe",
        email: "janedoe@example.com",
        link: "https://example.com/janedoe"
      },
      {
        name: "Joe Smith",
        email: "joesmith@example.com",
        link: "https://example.com/joesmith"
      }
    ],
    contributor: [
      {
        name: "Shawn Kemp",
        email: "shawnkemp@example.com",
        link: "https://example.com/shawnkemp"
      },
      {
        name: "Reggie Miller",
        email: "reggiemiller@example.com",
        link: "https://example.com/reggiemiller"
      }
    ],
    date: post.date,
    image: post.image
  });
});

feed.addCategory("Technologie");

feed.addContributor({
  name: "Johan Cruyff",
  email: "johancruyff@example.com",
  link: "https://example.com/johancruyff"
});

console.log(feed.rss2());
// Output: RSS 2.0

console.log(feed.atom1());
// Output: Atom 1.0

console.log(feed.json1());
// Output: JSON Feed 1.0

Migrating from < 3.0.0

If you are migrating from a version older than 3.0.0, be sure to update your import as we migrated to ES6 named imports.

If your environment supports the ES6 module syntax, you can import as described above:

import { Feed } from "feed";

Otherwise, you can stick with require():

- const Feed = require('feed');
+ const Feed = require('feed').Feed;

More Information

License

Copyright (C) 2013, Jean-Philippe Monette contact@jpmonette.net

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

changelog

Change Log

4.2.2 (2021-01-22)

Full Changelog

Implemented enhancements:

  • Export types in feed #128

Merged pull requests:

4.2.1 (2020-07-05)

Full Changelog

Closed issues:

  • RSS pubDate set to "date" rather than "published", unlike Atom #117

Merged pull requests:

  • Sanitizing XML feeds #125 (decebal)
  • author.uri and author.email should be optional in atom #115 #124 (decebal)
  • fix: 🐛 overwrite pubDate on rss when published is specified #121 (decebal)

4.2.0 (2020-05-25)

Full Changelog

Closed issues:

  • Getting an error during Netlify deploy (and npm run build) #118
  • atom:link in RSS feed should point to self, not atom #113

Merged pull requests:

4.1.0 (2019-12-29)

Full Changelog

Closed issues:

  • Update the default of date on atom to be published #108
  • export base xml-js object #102
  • Add extra attributes on <rss> tag #98
  • item.id is ignored in rss output #96
  • How to generate <dc:creator> #90
  • Specify namespace and custom attributes #88

Merged pull requests:

4.0.0 (2019-07-06)

Full Changelog

Merged pull requests:

3.0.0 (2019-05-28)

Full Changelog

Merged pull requests:

2.0.4 (2019-03-02)

Full Changelog

Implemented enhancements:

  • Feed support for Category on Items #71

Closed issues:

  • TypeError: Feed is not a constructor #80
  • Example Code, posts Undefined #78
  • npm package broken #77
  • Cannot display the publish time of essay correctly. #67
  • Feedly.com not accepting it #62
  • TypeError: d.getUTCFullYear is not a function #59
  • Extra properties #57
  • Support paged feeds #52
  • RSS author is still (again) broken #50
  • writing feed as a stream of articles [feature request] #44
  • New line is not transformed to
    #42
  • I would like to provide some custom namespace for my item nodes #38
  • Missing 'type="image/*"' attribute for image enclosures #37
  • How to append items to an existing RSS-2.0 Feed #33
  • Namespace prefix content on encoded is not defined #32
  • support for multiple enclosures in one item? #31

Merged pull requests:

2.0.0 (2018-08-04)

Full Changelog

Closed issues:

  • Items in feed not added image property #63

Merged pull requests:

1.1.0 (2017-06-03)

Full Changelog

Closed issues:

  • </link> stripped out #53
  • "updated" broken #51
  • validateURL is not nice function #23

Merged pull requests:

1.0.1 (2017-04-02)

Implemented enhancements:

  • Allow for manual setting of the feed updated date #14
  • Readme should mention missing stuff #3
  • Tests #2
  • Author fields in feed items? #1

Fixed bugs:

  • Forgot a "console.log" #5

Closed issues:

  • Cut a new release #47
  • RSS author tag for each post should contain only email #41
  • URL in repo description is a dead link #36
  • Lots of commits missing in npm #35
  • AppFog 404 Not Found #20
  • Generated Atom feed has a few problems according to validator #19
  • content encoding #17
  • TypeError: Object July 21, 1983 01:15:00 has no method 'toUTCString' #11
  • The code breaks when atom feed is requested #8
  • Author email and link should be optional #6

Merged pull requests:

* This Change Log was automatically generated by github_changelog_generator