88[ ![ Backers] [ backers-badge ]] [ collective ]
99[ ![ Chat] [ chat-badge ]] [ chat ]
1010
11- [ xast] [ ] utility to build (web) feeds ([ RSS] [ ] , [ Atom] [ ] ).
11+ [ xast] [ ] utility to build (web) feeds ([ RSS] [ rss-spec ] , [ Atom] [ atom-spec ] ).
1212
1313## Contents
1414
1717* [ Install] ( #install )
1818* [ Use] ( #use )
1919* [ API] ( #api )
20- * [ ` rss(channel, data) ` ] ( #rsschannel-data )
2120 * [ ` atom(channel, data) ` ] ( #atomchannel-data )
22- * [ ` Channel ` ] ( #channel-1 )
21+ * [ ` rss(channel, data) ` ] ( #rsschannel-data )
22+ * [ ` Author ` ] ( #author )
23+ * [ ` Channel ` ] ( #channel )
24+ * [ ` Enclosure ` ] ( #enclosure )
2325 * [ ` Entry ` ] ( #entry )
2426* [ Types] ( #types )
2527* [ Compatibility] ( #compatibility )
@@ -52,7 +54,7 @@ Just using either RSS or Atom is probably fine: no need to do both.
5254## Install
5355
5456This package is [ ESM only] [ esm ] .
55- In Node.js (version 12.20+, 14.14+, 16.0+, or 18 .0+), install with [ npm] [ ] :
57+ In Node.js (version 14.14+ and 16 .0+), install with [ npm] [ ] :
5658
5759``` sh
5860npm install xast-util-feed
@@ -165,142 +167,194 @@ Yields (pretty printed):
165167
166168## API
167169
168- This package exports the identifiers ` atom ` and ` rss ` .
170+ This package exports the identifiers [ ` atom ` ] [ atom ] and [ ` rss ` ] [ rss ] .
169171There is no default export.
170172
171- ### ` rss (channel, data)`
173+ ### ` atom (channel, data)`
172174
173- Build an RSS feed.
175+ Build an [ Atom ] [ atom-spec ] feed.
174176
175- ###### ` channel `
177+ ###### Parameters
176178
177- See [ ` Channel ` ] [ channel ] .
179+ * ` channel ` ([ ` Channel ` ] [ channel ] )
180+ — data on the feed (the group of items)
181+ * ` data ` ([ ` Array<Entry> ` ] [ entry ] , optional)
182+ — list of entries
178183
179- ###### ` data `
184+ ###### Returns
185+
186+ Atom feed ([ ` Root ` ] [ root ] ).
180187
181- List of [ ` Entry ` ] [ entry ] objects.
188+ ### ` rss(channel, data) `
189+
190+ Build an [ RSS] [ rss-spec ] feed.
191+
192+ ###### Parameters
193+
194+ * ` channel ` ([ ` Channel ` ] [ channel ] )
195+ — data on the feed (the group of items)
196+ * ` data ` ([ ` Array<Entry> ` ] [ entry ] , optional)
197+ — list of entries
182198
183199###### Returns
184200
185- [ xast ] [ ] root ([ ` Root ` ] [ root ] ).
201+ RSS feed ([ ` Root ` ] [ root ] ).
186202
187- ### ` atom(channel, data) `
203+ ### ` Author `
204+
205+ Author object (TypeScript type).
206+
207+ ##### Fields
188208
189- Build an Atom feed.
190- Same API as ` rss ` otherwise.
209+ ###### ` name `
210+
211+ Name (` string ` , ** required** , example: ` 'Acme, Inc.' ` or ` 'Jane Doe' ` ).
212+
213+ ###### ` email `
214+
215+ Email address (` string ` , optional, ,example: ` john@example.org ` )
216+
217+ ###### ` url `
218+
219+ URL to author (` string ` , optional, example: ` 'https://example.org/john' ` ).
220+
221+ ` url ` is used in ` atom ` , not in ` rss ` .
191222
192223### ` Channel `
193224
194- Data on the feed (the group of items).
225+ Data on the feed (the group of items) (TypeScript type) .
195226
196- ###### ` channel.title `
227+ ##### Fields
228+
229+ ###### ` title `
197230
198231Title of the channel (` string ` , ** required** , example: `Zimbabwe | The
199232Guardian`).
200233
201- ###### ` channel. url`
234+ ###### ` url `
202235
203236Full URL to the * site* (` string ` , ** required** , example:
204237` 'https://www.theguardian.com/world/zimbabwe' ` ).
205238
206- ###### ` channel. feedUrl`
239+ ###### ` feedUrl `
207240
208241Full URL to this channel (` string? ` , example: ` 'https://www.adweek.com/feed/' ` ).
242+
209243Make sure to pass different ones to ` rss ` and ` atom ` when you build both!
244+
210245You * should* define this.
211246
212- ###### ` channel. description`
247+ ###### ` description `
213248
214249Short description of the channel (` string? ` , example: ` Album Reviews ` ).
250+
215251You * should* define this.
216252
217- ###### ` channel. lang`
253+ ###### ` lang `
218254
219255[ BCP 47] [ bcp47 ] language tag representing the language of the whole channel
220256(` string? ` , example: ` 'fr-BE' ` ).
221- You * should* define this.
222257
223- ###### ` channel.author `
258+ You * should * define this.
224259
225- Optional author of the whole channel.
226- Either ` string ` , in which case it’s as passing ` {name: string} ` .
227- Or an object with the following fields:
260+ ###### ` author `
228261
229- * ` name ` (` string ` , example: ` 'Acme, Inc.' ` or ` 'Jane Doe' ` )
230- * ` email ` (` string? ` , example: ` john@example.org ` )
231- * ` url ` (` string? ` , example: ` 'https://example.org/john' ` )
262+ Optional author of the whole channel (` string ` or [ ` Author ` ] [ author ] ).
232263
233- ` url ` is used in ` atom ` , not in ` rss ` .
264+ Either ` string ` , in which case it’s as passing ` {name: string} ` .
265+ Or an author object.
234266
235- ###### ` channel. tags`
267+ ###### ` tags `
236268
237269Categories of the channel (` Array<string>? ` , example: `[ 'JavaScript',
238270'React'] `).
239271
272+ ### ` Enclosure `
273+
274+ Media (TypeScript type).
275+
276+ ##### Fields
277+
278+ ###### ` url `
279+
280+ Full URL to the resource (` string ` , ** required** , example:
281+ ` 'http://dallas.example.com/joebob_050689.mp3' ` ).
282+
283+ ###### ` size `
284+
285+ Resource size in bytes (` number ` , ** required** , example: ` 24986239 ` ).
286+
287+ ###### ` type `
288+
289+ Mime type of the resource (` string ` , ** required** , example: ` 'audio/mpeg' ` ).
290+
240291### ` Entry `
241292
242- Data on a single item.
293+ Data on a single item (TypeScript type).
294+
295+ ##### Fields
243296
244- ###### ` entry. title`
297+ ###### ` title `
245298
246299Title of the item (` string? ` , example: ` 'Playboi Carti: Whole Lotta Red' ` ).
300+
247301Either ` title ` , ` description ` , or ` descriptionHtml ` must be set.
248302
249- ###### ` entry. description`
303+ ###### ` description `
250304
251305Either the whole post or an excerpt of it (` string? ` , example: ` 'Lorem' ` ).
306+
252307Should be plain text.
253308` descriptionHtml ` is preferred over plain text ` description ` .
309+
254310Either ` title ` , ` description ` , or ` descriptionHtml ` must be set.
255311
256- ###### ` entry. descriptionHtml`
312+ ###### ` descriptionHtml `
257313
258314Either the whole post or an excerpt of it (` string? ` , example: ` '<p>Lorem</p>' ` ).
315+
259316Should be serialized HTML.
260317` descriptionHtml ` is preferred over plain text ` description ` .
318+
261319Either ` title ` , ` description ` , or ` descriptionHtml ` must be set.
262320
263- ###### ` entry.author `
321+ ###### ` author `
322+
323+ Entry version of ` channel.author ` .
264324
265- Entry version of [ ` channel.author ` ] [ channel-author ] .
266325You * should* define this.
326+
267327For ` atom ` , it is required to either set ` channel.author ` or set ` author ` on all
268328entries.
269329
270- ###### ` entry. url`
330+ ###### ` url `
271331
272332Full URL of this entry on the * site* (` string? ` , example:
273333` 'https://pitchfork.com/reviews/albums/roberta-flack-first-take' ` ).
274334
275- ###### ` entry. published`
335+ ###### ` published `
276336
277337When the entry was first published (` Date ` or value for ` new Date(x) ` ,
278338optional).
279339
280- ###### ` entry. modified`
340+ ###### ` modified `
281341
282342When the entry was last modified (` Date ` or value for ` new Date(x) ` , optional).
283343
284- ###### ` entry. tags`
344+ ###### ` tags `
285345
286346Categories of the entry (` Array<string>? ` , example: `[ 'laravel',
287347'debugging'] `).
288348
289- ###### ` entry. enclosure`
349+ ###### ` enclosure `
290350
291- An enclosure, such as an image or audio, is an object with the following fields:
292-
293- * ` url ` (` string ` , example: ` 'http://dallas.example.com/joebob_050689.mp3' ` )
294- — full URL to the resource
295- * ` size ` (` number ` , example: ` 24986239 ` )
296- — resource size in bytes
297- * ` type ` (` string ` , example: ` 'audio/mpeg' ` )
298- — mime type of the resource
351+ Attached media ([ ` Enclosure? ` ] [ enclosure ] ).
299352
300353## Types
301354
302355This package is fully typed with [ TypeScript] [ ] .
303- It exports the additional types ` Author ` , ` Enclosure ` , ` Channel ` , and ` Entry ` .
356+ It exports the additional types [ ` Author ` ] [ author ] , [ ` Channel ` ] [ channel ] ,
357+ [ ` Enclosure ` ] [ enclosure ] , and [ ` Entry ` ] [ entry ] .
304358
305359## Compatibility
306360
@@ -334,7 +388,7 @@ abide by its terms.
334388
335389## License
336390
337- [ MIT] [ license ] © [ Titus Wormer] [ author ]
391+ [ MIT] [ license ] © [ Titus Wormer] [ wooorm ]
338392
339393<!-- Definitions -->
340394
@@ -374,7 +428,7 @@ abide by its terms.
374428
375429[ license ] : license
376430
377- [ author ] : https://wooorm.com
431+ [ wooorm ] : https://wooorm.com
378432
379433[ health ] : https://github.com/syntax-tree/.github
380434
@@ -388,14 +442,20 @@ abide by its terms.
388442
389443[ root ] : https://github.com/syntax-tree/xast#root
390444
391- [ rss ] : https://www.rssboard.org/rss-specification
445+ [ rss-spec ] : https://www.rssboard.org/rss-specification
392446
393- [ atom ] : https://tools.ietf.org/html/rfc4287
447+ [ atom-spec ] : https://tools.ietf.org/html/rfc4287
394448
395449[ bcp47 ] : https://github.com/wooorm/bcp-47
396450
451+ [ atom ] : #atomchannel-data
452+
453+ [ rss ] : #rsschannel-data
454+
455+ [ author ] : #author
456+
397457[ channel ] : #channel
398458
399- [ entry ] : #entry
459+ [ enclosure ] : #enclosure
400460
401- [ channel-author ] : #channelauthor
461+ [ entry ] : #entry
0 commit comments