UNPKG

5.18 kBMarkdownView Raw
1<p align="center">
2 <img src="https://user-images.githubusercontent.com/1114325/60746552-2c059a00-9f77-11e9-9632-e21dea9dd06b.png" alt="Feed for Node.js" width="326">
3 <br>
4 <a href="https://travis-ci.org/jpmonette/feed"><img src="https://travis-ci.org/jpmonette/feed.svg?branch=master" alt="Build Status"></a> <a href='https://coveralls.io/github/jpmonette/feed?branch=master'><img src='https://coveralls.io/repos/github/jpmonette/feed/badge.svg?branch=master' alt='Coverage Status' /></a> <a href="https://badge.fury.io/js/feed"><img src="https://badge.fury.io/js/feed.svg" alt="npm version" height="18"></a> <a href="https://github.com/facebook/jest"><img src="https://img.shields.io/badge/tested_with-jest-99424f.svg" alt="Tested with Jest"></a> <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
5</p>
6<p align="center"><code>jpmonette/feed</code> - <strong>RSS 2.0, JSON Feed 1.0, and Atom 1.0</strong> generator for <strong>Node.js</strong><br>
7Making content syndication simple and intuitive!</p>
8
9---
10
11**👩🏻‍💻 Developer Ready**: Quickly generate syndication feeds for your Website.
12
13**💪🏼 Strongly Typed**: Developed using TypeScript / type-safe.
14
15**🔒 Tested**: Tests & snapshot for each syndication format to avoid regressions.
16
17# Getting Started
18
19## Installation
20
21```bash
22$ yarn add feed
23```
24
25## Example
26
27```js
28import { Feed } from "feed";
29
30const feed = new Feed({
31 title: "Feed Title",
32 description: "This is my personal feed!",
33 id: "http://example.com/",
34 link: "http://example.com/",
35 language: "en", // optional, used only in RSS 2.0, possible values: http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
36 image: "http://example.com/image.png",
37 favicon: "http://example.com/favicon.ico",
38 copyright: "All rights reserved 2013, John Doe",
39 updated: new Date(2013, 6, 14), // optional, default = today
40 generator: "awesome", // optional, default = 'Feed for Node.js'
41 feedLinks: {
42 json: "https://example.com/json",
43 atom: "https://example.com/atom"
44 },
45 author: {
46 name: "John Doe",
47 email: "johndoe@example.com",
48 link: "https://example.com/johndoe"
49 }
50});
51
52posts.forEach(post => {
53 feed.addItem({
54 title: post.title,
55 id: post.url,
56 link: post.url,
57 description: post.description,
58 content: post.content,
59 author: [
60 {
61 name: "Jane Doe",
62 email: "janedoe@example.com",
63 link: "https://example.com/janedoe"
64 },
65 {
66 name: "Joe Smith",
67 email: "joesmith@example.com",
68 link: "https://example.com/joesmith"
69 }
70 ],
71 contributor: [
72 {
73 name: "Shawn Kemp",
74 email: "shawnkemp@example.com",
75 link: "https://example.com/shawnkemp"
76 },
77 {
78 name: "Reggie Miller",
79 email: "reggiemiller@example.com",
80 link: "https://example.com/reggiemiller"
81 }
82 ],
83 date: post.date,
84 image: post.image
85 });
86});
87
88feed.addCategory("Technologie");
89
90feed.addContributor({
91 name: "Johan Cruyff",
92 email: "johancruyff@example.com",
93 link: "https://example.com/johancruyff"
94});
95
96console.log(feed.rss2());
97// Output: RSS 2.0
98
99console.log(feed.atom1());
100// Output: Atom 1.0
101
102console.log(feed.json1());
103// Output: JSON Feed 1.0
104```
105
106## Migrating from `< 3.0.0`
107
108If you are migrating from a version older than `3.0.0`, be sure to update your import as we migrated to ES6 named imports.
109
110If your environment supports the ES6 module syntax, you can `import` as described above:
111
112```ts
113import { Feed } from "feed";
114```
115
116Otherwise, you can stick with `require()`:
117
118```diff
119- const Feed = require('feed');
120+ const Feed = require('feed').Feed;
121```
122
123## More Information
124
125- Follow [@jpmonette](https://twitter.com/jpmonette) on Twitter for updates
126- Read my personal blog [Blogue de Jean-Philippe Monette](http://blogue.jpmonette.net/) to learn more about what I do!
127
128## License
129
130Copyright (C) 2013, Jean-Philippe Monette <contact@jpmonette.net>
131
132Permission 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:
133
134The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
135
136THE 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.