@@ -41,31 +41,31 @@ npm install xast-util-feed
4141Say we have the following module, ` example.mjs `
4242
4343``` js
44- import {rss } from ' xast-util-feed'
44+ import {atom , rss } from ' xast-util-feed'
4545import toXml from ' xast-util-to-xml'
4646
47- var tree = rss (
47+ var channel = {
48+ title: ' NYT > Top Stories' ,
49+ url: ' https://www.nytimes.com' ,
50+ feedUrl: ' https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml' ,
51+ lang: ' en' ,
52+ author: ' The New York Times Company'
53+ }
54+
55+ var data = [
4856 {
49- title: ' NYT > Top Stories' ,
50- url: ' https://www.nytimes.com' ,
51- feedUrl: ' https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml' ,
52- lang: ' en' ,
53- author: ' The New York Times Company'
54- },
55- [
56- {
57- title: ' Senate Balances Impeachment Trial With an Incoming President' ,
58- url:
59- ' https://www.nytimes.com/2021/01/14/us/politics/impeachment-senate-trial-trump.html' ,
60- description: ' Senate leaders etc etc etc.' ,
61- author: ' Nicholas Fandos and Catie Edmondson' ,
62- published: ' Fri, 15 Jan 2021 01:18:49 +0000' ,
63- tags: [' Senate' , ' Murkowski, Lisa' , ' Trump, Donald J' ]
64- }
65- ]
66- )
67-
68- console .log (toXml (tree))
57+ title: ' Senate Balances Impeachment Trial With an Incoming President' ,
58+ url:
59+ ' https://www.nytimes.com/2021/01/14/us/politics/impeachment-senate-trial-trump.html' ,
60+ descriptionHtml: ' <p>Senate leaders etc etc etc.</p>' ,
61+ author: ' Nicholas Fandos and Catie Edmondson' ,
62+ published: ' Fri, 15 Jan 2021 01:18:49 +0000' ,
63+ tags: [' Senate' , ' Murkowski, Lisa' , ' Trump, Donald J' ]
64+ }
65+ ]
66+
67+ console .log (toXml (rss (channel, data)))
68+ console .log (toXml (atom (channel, data)))
6969```
7070
7171Now, running ` node example.mjs ` yields (pretty printed):
@@ -77,9 +77,9 @@ Now, running `node example.mjs` yields (pretty printed):
7777 <title >NYT > Top Stories</title >
7878 <description ></description >
7979 <link >https://www.nytimes.com/</link >
80- <lastBuildDate >Fri, 15 Jan 2021 11:38:12 GMT</lastBuildDate >
81- <dc : date >2021-01-15T11:38:12.052Z </dc : date >
82- <atom : link href =" https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml" rel =" self" type =" application/rss+xml" / >
80+ <lastBuildDate >Sun, 17 Jan 2021 09:00:54 GMT</lastBuildDate >
81+ <dc : date >2021-01-17T09:00:54.781Z </dc : date >
82+ <atom : link href =" https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml" rel =" self" type =" application/rss+xml" ></ atom : link >
8383 <language >en</language >
8484 <dc : language >en</dc : language >
8585 <copyright >© 2021 The New York Times Company</copyright >
@@ -94,12 +94,41 @@ Now, running `node example.mjs` yields (pretty printed):
9494 <category >Senate</category >
9595 <category >Murkowski, Lisa</category >
9696 <category >Trump, Donald J</category >
97- <description >Senate leaders etc etc etc.</description >
97+ <description >< p> Senate leaders etc etc etc.< /p> </description >
9898 </item >
9999 </channel >
100100</rss >
101101```
102102
103+ ``` xml
104+ <?xml version =" 1.0" encoding =" utf-8" ?>
105+ <feed xmlns =" http://www.w3.org/2005/Atom" xml : lang =" en" >
106+ <title >NYT > Top Stories</title >
107+ <subtitle ></subtitle >
108+ <link >https://www.nytimes.com/</link >
109+ <id >https://www.nytimes.com/</id >
110+ <updated >Sun, 17 Jan 2021 09:00:54 GMT</updated >
111+ <link href =" https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml" rel =" self" type =" application/atom+xml" ></link >
112+ <rights >© 2021 The New York Times Company</rights >
113+ <author >
114+ <name >The New York Times Company</name >
115+ </author >
116+ <category term =" Senate" ></category >
117+ <category term =" Murkowski, Lisa" ></category >
118+ <category term =" Trump, Donald J" ></category >
119+ <entry >
120+ <title >Senate Balances Impeachment Trial With an Incoming President</title >
121+ <author >
122+ <name >Nicholas Fandos and Catie Edmondson</name >
123+ </author >
124+ <link href =" https://www.nytimes.com/2021/01/14/us/politics/impeachment-senate-trial-trump.html" ></link >
125+ <id >https://www.nytimes.com/2021/01/14/us/politics/impeachment-senate-trial-trump.html</id >
126+ <published >2021-01-15T01:18:49.000Z</published >
127+ <content type =" html" >< p>Senate leaders etc etc etc.< /p></content >
128+ </entry >
129+ </feed >
130+ ```
131+
103132## API
104133
105134### ` rss(channel, data) `
0 commit comments