8
8
[ ![ Backers] [ backers-badge ]] [ collective ]
9
9
[ ![ Chat] [ chat-badge ]] [ chat ]
10
10
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.
15
39
It has a few good options instead of overwhelming with hundreds of things to
16
40
configure.
17
41
If you do need more things, well: this utility gives you a syntax tree, which
@@ -20,25 +44,35 @@ you can change.
20
44
It’s good to use this package to build several feeds and to only include recent
21
45
posts (often 15-20 items are included in a channel).
22
46
You 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).
25
49
26
50
Just using either RSS or Atom is probably fine: no need to do both.
27
51
28
52
## Install
29
53
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] [ ] :
34
56
35
57
``` sh
36
58
npm install xast-util-feed
37
59
```
38
60
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
+ ```
40
74
41
- Say we have the following module, ` example.js `
75
+ ## Use
42
76
43
77
``` js
44
78
import {atom , rss } from ' xast-util-feed'
@@ -68,7 +102,7 @@ console.log(toXml(rss(channel, data)))
68
102
console .log (toXml (atom (channel, data)))
69
103
```
70
104
71
- Now, running ` node example.js ` yields (pretty printed):
105
+ Yields (pretty printed):
72
106
73
107
``` xml
74
108
<?xml version =" 1.0" encoding =" utf-8" ?>
@@ -131,7 +165,7 @@ Now, running `node example.js` yields (pretty printed):
131
165
132
166
## API
133
167
134
- This package exports the following identifiers: ` atom ` , ` rss ` .
168
+ This package exports the identifiers ` atom ` and ` rss ` .
135
169
There is no default export.
136
170
137
171
### ` rss(channel, data) `
@@ -148,7 +182,7 @@ List of [`Entry`][entry] objects.
148
182
149
183
###### Returns
150
184
151
- [ ` Root ` ] [ root ] — [ xast ] [ ] root.
185
+ [ xast ] [ ] root ( [ ` Root ` ] [ root ] ) .
152
186
153
187
### ` atom(channel, data) `
154
188
@@ -172,7 +206,7 @@ Full URL to the *site* (`string`, **required**, example:
172
206
###### ` channel.feedUrl `
173
207
174
208
Full 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 !
176
210
You * should* define this.
177
211
178
212
###### ` channel.description `
@@ -257,11 +291,23 @@ Categories of the entry (`Array<string>?`, example: `['laravel',
257
291
An enclosure, such as an image or audio, is an object with the following fields:
258
292
259
293
* ` url ` (` string ` , example: ` 'http://dallas.example.com/joebob_050689.mp3' ` )
260
- — Full URL to the resource
294
+ — full URL to the resource
261
295
* ` size ` (` number ` , example: ` 24986239 ` )
262
- — Resource size in bytes
296
+ — resource size in bytes
263
297
* ` 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.
265
311
266
312
## Security
267
313
@@ -278,8 +324,8 @@ XML can be a dangerous language: don’t trust user-provided data.
278
324
279
325
## Contribute
280
326
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.
283
329
See [ ` support.md ` ] [ support ] for ways to get help.
284
330
285
331
This project has a [ code of conduct] [ coc ] .
@@ -320,15 +366,23 @@ abide by its terms.
320
366
321
367
[ npm ] : https://docs.npmjs.com/cli/install
322
368
369
+ [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
370
+
371
+ [ esmsh ] : https://esm.sh
372
+
373
+ [ typescript ] : https://www.typescriptlang.org
374
+
323
375
[ license ] : license
324
376
325
377
[ author ] : https://wooorm.com
326
378
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
328
382
329
- [ support ] : https://github.com/syntax-tree/.github/blob/HEAD /support.md
383
+ [ support ] : https://github.com/syntax-tree/.github/blob/main /support.md
330
384
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
332
386
333
387
[ xast ] : https://github.com/syntax-tree/xast
334
388
0 commit comments