88[ ![ Backers] [ backers-badge ]] [ collective ]
99[ ![ Chat] [ chat-badge ]] [ chat ]
1010
11- ** [ xast] [ ] ** utility to build (web) feeds ([ RSS] [ ] , [ Atom] [ ] ).
12-
13- This package focusses on a small set of widely used and supported parts of
14- feeds.
11+ [ xast] [ ] utility to build (web) feeds ([ RSS] [ ] , [ Atom] [ ] ).
12+
13+ ## Contents
14+
15+ * [ What is this?] ( #what-is-this )
16+ * [ When should I use this?] ( #when-should-i-use-this )
17+ * [ Install] ( #install )
18+ * [ Use] ( #use )
19+ * [ API] ( #api )
20+ * [ ` rss(channel, data) ` ] ( #rsschannel-data )
21+ * [ ` atom(channel, data) ` ] ( #atomchannel-data )
22+ * [ ` Channel ` ] ( #channel-1 )
23+ * [ ` Entry ` ] ( #entry )
24+ * [ Types] ( #types )
25+ * [ Compatibility] ( #compatibility )
26+ * [ Security] ( #security )
27+ * [ Related] ( #related )
28+ * [ Contribute] ( #contribute )
29+ * [ License] ( #license )
30+
31+ ## What is this?
32+
33+ This package generates RSS or Atom feeds from data.
34+
35+ ## When should I use this?
36+
37+ This package helps you add feeds to your site.
38+ It focusses on a small set of widely used and supported parts of feeds.
1539It has a few good options instead of overwhelming with hundreds of things to
1640configure.
1741If you do need more things, well: this utility gives you a syntax tree, which
@@ -20,25 +44,35 @@ you can change.
2044It’s good to use this package to build several feeds and to only include recent
2145posts (often 15-20 items are included in a channel).
2246You should make a channel for all your posts; when relevant, separate channels
23- per language; and potentially, channels per post type (e.g., separate ones for
24- blog posts, notes, and images).
47+ per language as well ; and potentially, channels per post type (such as separate
48+ ones for blog posts, notes, and images).
2549
2650Just using either RSS or Atom is probably fine: no need to do both.
2751
2852## Install
2953
30- This package is [ ESM only] ( https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c ) :
31- Node 12+ is needed to use it and it must be ` import ` ed instead of ` require ` d.
32-
33- [ npm] [ ] :
54+ This package is [ ESM only] [ esm ] .
55+ In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with [ npm] [ ] :
3456
3557``` sh
3658npm install xast-util-feed
3759```
3860
39- ## Use
61+ In Deno with [ ` esm.sh ` ] [ esmsh ] :
62+
63+ ``` js
64+ import {atom , rss } from ' https://esm.sh/xast-util-feed@1'
65+ ```
66+
67+ In browsers with [ ` esm.sh ` ] [ esmsh ] :
68+
69+ ``` html
70+ <script type =" module" >
71+ import {atom , rss } from ' https://esm.sh/xast-util-feed@1?bundle'
72+ </script >
73+ ```
4074
41- Say we have the following module, ` example.js `
75+ ## Use
4276
4377``` js
4478import {atom , rss } from ' xast-util-feed'
@@ -68,7 +102,7 @@ console.log(toXml(rss(channel, data)))
68102console .log (toXml (atom (channel, data)))
69103```
70104
71- Now, running ` node example.js ` yields (pretty printed):
105+ Yields (pretty printed):
72106
73107``` xml
74108<?xml version =" 1.0" encoding =" utf-8" ?>
@@ -131,7 +165,7 @@ Now, running `node example.js` yields (pretty printed):
131165
132166## API
133167
134- This package exports the following identifiers: ` atom ` , ` rss ` .
168+ This package exports the identifiers ` atom ` and ` rss ` .
135169There is no default export.
136170
137171### ` rss(channel, data) `
@@ -148,7 +182,7 @@ List of [`Entry`][entry] objects.
148182
149183###### Returns
150184
151- [ ` Root ` ] [ root ] — [ xast ] [ ] root.
185+ [ xast ] [ ] root ( [ ` Root ` ] [ root ] ) .
152186
153187### ` atom(channel, data) `
154188
@@ -172,7 +206,7 @@ Full URL to the *site* (`string`, **required**, example:
172206###### ` channel.feedUrl `
173207
174208Full URL to this channel (` string? ` , example: ` 'https://www.adweek.com/feed/' ` ).
175- Make sure to pass different ones to ` rss ` and ` atom ` !
209+ Make sure to pass different ones to ` rss ` and ` atom ` when you build both !
176210You * should* define this.
177211
178212###### ` channel.description `
@@ -257,11 +291,23 @@ Categories of the entry (`Array<string>?`, example: `['laravel',
257291An enclosure, such as an image or audio, is an object with the following fields:
258292
259293* ` url ` (` string ` , example: ` 'http://dallas.example.com/joebob_050689.mp3' ` )
260- — Full URL to the resource
294+ — full URL to the resource
261295* ` size ` (` number ` , example: ` 24986239 ` )
262- — Resource size in bytes
296+ — resource size in bytes
263297* ` type ` (` string ` , example: ` 'audio/mpeg' ` )
264- — Mime type of the resource
298+ — mime type of the resource
299+
300+ ## Types
301+
302+ This package is fully typed with [ TypeScript] [ ] .
303+ It exports the additional types ` Author ` , ` Enclosure ` , ` Channel ` , and ` Entry ` .
304+
305+ ## Compatibility
306+
307+ Projects maintained by the unified collective are compatible with all maintained
308+ versions of Node.js.
309+ As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
310+ Our projects sometimes work with older versions, but this is not guaranteed.
265311
266312## Security
267313
@@ -278,8 +324,8 @@ XML can be a dangerous language: don’t trust user-provided data.
278324
279325## Contribute
280326
281- See [ ` contributing.md ` in ` syntax-tree/.github ` ] [ contributing ] for ways to get
282- started.
327+ See [ ` contributing.md ` ] [ contributing ] in [ ` syntax-tree/.github ` ] [ health ] for
328+ ways to get started.
283329See [ ` support.md ` ] [ support ] for ways to get help.
284330
285331This project has a [ code of conduct] [ coc ] .
@@ -320,15 +366,23 @@ abide by its terms.
320366
321367[ npm ] : https://docs.npmjs.com/cli/install
322368
369+ [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
370+
371+ [ esmsh ] : https://esm.sh
372+
373+ [ typescript ] : https://www.typescriptlang.org
374+
323375[ license ] : license
324376
325377[ author ] : https://wooorm.com
326378
327- [ contributing ] : https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
379+ [ health ] : https://github.com/syntax-tree/.github
380+
381+ [ contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing.md
328382
329- [ support ] : https://github.com/syntax-tree/.github/blob/HEAD /support.md
383+ [ support ] : https://github.com/syntax-tree/.github/blob/main /support.md
330384
331- [ coc ] : https://github.com/syntax-tree/.github/blob/HEAD /code-of-conduct.md
385+ [ coc ] : https://github.com/syntax-tree/.github/blob/main /code-of-conduct.md
332386
333387[ xast ] : https://github.com/syntax-tree/xast
334388
0 commit comments