@@ -44,6 +44,8 @@ const web1FeedItemWithContent = {
4444// prettier-ignore
4545const validXmlResult = `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><title><![CDATA[${ title } ]]></title><description><![CDATA[${ description } ]]></description><link>${ site } /</link><item><title><![CDATA[${ phpFeedItem . title } ]]></title><link>${ site } ${ phpFeedItem . link } /</link><guid>${ site } ${ phpFeedItem . link } /</guid><description><![CDATA[${ phpFeedItem . description } ]]></description><pubDate>${ new Date ( phpFeedItem . pubDate ) . toUTCString ( ) } </pubDate></item><item><title><![CDATA[${ web1FeedItem . title } ]]></title><link>${ site } ${ web1FeedItem . link } /</link><guid>${ site } ${ web1FeedItem . link } /</guid><description><![CDATA[${ web1FeedItem . description } ]]></description><pubDate>${ new Date ( web1FeedItem . pubDate ) . toUTCString ( ) } </pubDate></item></channel></rss>` ;
4646// prettier-ignore
47+ const validXmlWithoutWeb1FeedResult = `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><title><![CDATA[${ title } ]]></title><description><![CDATA[${ description } ]]></description><link>${ site } /</link><item><title><![CDATA[${ phpFeedItem . title } ]]></title><link>${ site } ${ phpFeedItem . link } /</link><guid>${ site } ${ phpFeedItem . link } /</guid><description><![CDATA[${ phpFeedItem . description } ]]></description><pubDate>${ new Date ( phpFeedItem . pubDate ) . toUTCString ( ) } </pubDate></item></channel></rss>` ;
48+ // prettier-ignore
4749const validXmlWithContentResult = `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title><![CDATA[${ title } ]]></title><description><![CDATA[${ description } ]]></description><link>${ site } /</link><item><title><![CDATA[${ phpFeedItemWithContent . title } ]]></title><link>${ site } ${ phpFeedItemWithContent . link } /</link><guid>${ site } ${ phpFeedItemWithContent . link } /</guid><description><![CDATA[${ phpFeedItemWithContent . description } ]]></description><pubDate>${ new Date ( phpFeedItemWithContent . pubDate ) . toUTCString ( ) } </pubDate><content:encoded><![CDATA[${ phpFeedItemWithContent . content } ]]></content:encoded></item><item><title><![CDATA[${ web1FeedItemWithContent . title } ]]></title><link>${ site } ${ web1FeedItemWithContent . link } /</link><guid>${ site } ${ web1FeedItemWithContent . link } /</guid><description><![CDATA[${ web1FeedItemWithContent . description } ]]></description><pubDate>${ new Date ( web1FeedItemWithContent . pubDate ) . toUTCString ( ) } </pubDate><content:encoded><![CDATA[${ web1FeedItemWithContent . content } ]]></content:encoded></item></channel></rss>` ;
4850// prettier-ignore
4951const validXmlWithCustomDataResult = `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title><![CDATA[${ title } ]]></title><description><![CDATA[${ description } ]]></description><link>${ site } /</link><item><title><![CDATA[${ phpFeedItemWithCustomData . title } ]]></title><link>${ site } ${ phpFeedItemWithCustomData . link } /</link><guid>${ site } ${ phpFeedItemWithCustomData . link } /</guid><description><![CDATA[${ phpFeedItemWithCustomData . description } ]]></description><pubDate>${ new Date ( phpFeedItemWithCustomData . pubDate ) . toUTCString ( ) } </pubDate>${ phpFeedItemWithCustomData . customData } </item><item><title><![CDATA[${ web1FeedItemWithContent . title } ]]></title><link>${ site } ${ web1FeedItemWithContent . link } /</link><guid>${ site } ${ web1FeedItemWithContent . link } /</guid><description><![CDATA[${ web1FeedItemWithContent . description } ]]></description><pubDate>${ new Date ( web1FeedItemWithContent . pubDate ) . toUTCString ( ) } </pubDate><content:encoded><![CDATA[${ web1FeedItemWithContent . content } ]]></content:encoded></item></channel></rss>` ;
@@ -195,6 +197,81 @@ describe('rss', () => {
195197 } )
196198 ) . to . be . rejected ;
197199 } ) ;
200+
201+ it ( 'should filter out draft' , async ( ) => {
202+ const globResult = {
203+ './posts/php.md' : ( ) =>
204+ new Promise ( ( resolve ) =>
205+ resolve ( {
206+ url : phpFeedItem . link ,
207+ frontmatter : {
208+ title : phpFeedItem . title ,
209+ pubDate : phpFeedItem . pubDate ,
210+ description : phpFeedItem . description ,
211+ } ,
212+ } )
213+ ) ,
214+ './posts/nested/web1.md' : ( ) =>
215+ new Promise ( ( resolve ) =>
216+ resolve ( {
217+ url : web1FeedItem . link ,
218+ frontmatter : {
219+ title : web1FeedItem . title ,
220+ pubDate : web1FeedItem . pubDate ,
221+ description : web1FeedItem . description ,
222+ draft : true ,
223+ } ,
224+ } )
225+ ) ,
226+ } ;
227+
228+ const { body } = await rss ( {
229+ title,
230+ description,
231+ items : globResult ,
232+ site,
233+ } ) ;
234+
235+ chai . expect ( body ) . xml . to . equal ( validXmlWithoutWeb1FeedResult ) ;
236+ } ) ;
237+
238+ it ( 'should respect drafts option' , async ( ) => {
239+ const globResult = {
240+ './posts/php.md' : ( ) =>
241+ new Promise ( ( resolve ) =>
242+ resolve ( {
243+ url : phpFeedItem . link ,
244+ frontmatter : {
245+ title : phpFeedItem . title ,
246+ pubDate : phpFeedItem . pubDate ,
247+ description : phpFeedItem . description ,
248+ } ,
249+ } )
250+ ) ,
251+ './posts/nested/web1.md' : ( ) =>
252+ new Promise ( ( resolve ) =>
253+ resolve ( {
254+ url : web1FeedItem . link ,
255+ frontmatter : {
256+ title : web1FeedItem . title ,
257+ pubDate : web1FeedItem . pubDate ,
258+ description : web1FeedItem . description ,
259+ draft : true ,
260+ } ,
261+ } )
262+ ) ,
263+ } ;
264+
265+ const { body } = await rss ( {
266+ title,
267+ description,
268+ items : globResult ,
269+ site,
270+ drafts : true ,
271+ } ) ;
272+
273+ chai . expect ( body ) . xml . to . equal ( validXmlResult ) ;
274+ } ) ;
198275 } ) ;
199276
200277 describe ( 'errors' , ( ) => {
0 commit comments