@@ -28,44 +28,41 @@ export class RssFeed extends BaseFeed<RssItem> {
2828 ` <lastBuildDate>${ this . options . updated ?. toUTCString ( ) } </lastBuildDate>\n` ,
2929 ` <language>${ this . options . language || "en" } </language>\n` ,
3030 ` <generator>${
31- this . options . generator || "Feed for Deno"
31+ escapeXml ( this . options . generator || "Feed for Deno" )
3232 } </generator>\n`,
3333 ] ;
3434
35- this . options . authors . forEach ( ( author ) => {
36- xmlParts . push (
37- ` <webMaster>${ escapeXml ( author . email ) } (${
38- escapeXml ( author . name )
39- } )</webMaster>\n`,
40- ` <author>${ escapeXml ( author . email ) } (${
41- escapeXml ( author . name )
42- } )</author>\n`,
43- ` <managingEditor>${ escapeXml ( author . email ) } (${
44- escapeXml ( author . name )
45- } )</managingEditor>\n`,
46- ) ;
47- } ) ;
35+ const authorXml = this . options . authors . map ( ( author ) =>
36+ ` <webMaster>${ escapeXml ( author . email ) } (${
37+ escapeXml ( author . name )
38+ } )</webMaster>\n` +
39+ ` <author>${ escapeXml ( author . email ) } (${
40+ escapeXml ( author . name )
41+ } )</author>\n` +
42+ ` <managingEditor>${ escapeXml ( author . email ) } (${
43+ escapeXml ( author . name )
44+ } )</managingEditor>\n`
45+ ) . join ( "" ) ;
46+ xmlParts . push ( authorXml ) ;
4847
49- this . items . forEach ( ( item ) => {
50- const itemParts : string [ ] = [
51- ` <item>\n` ,
52- ` <title>${ escapeXml ( item . title ) } </title>\n` ,
53- ` <link>${ escapeXml ( item . link ) } </link>\n` ,
54- ` <guid>${ escapeXml ( item . id ) } </guid>\n` ,
55- ` <pubDate>${ item . updated . toUTCString ( ) } </pubDate>\n` ,
56- ` <description>${ escapeXml ( item . description ) } </description>\n` ,
57- ] ;
58- if ( item . content ) {
59- const contentType = item . content . type || "text" ;
60- itemParts . push (
61- ` <content:encoded type="${ contentType } ">${
62- escapeXml ( item . content . body )
63- } </content:encoded>\n`,
64- ) ;
65- }
66- itemParts . push ( ` </item>\n` ) ;
67- xmlParts . push ( ...itemParts ) ;
68- } ) ;
48+ const itemsXml = this . items . map ( ( item ) => {
49+ const contentXml = item . content
50+ ? ` <content:encoded type="${
51+ escapeXml ( item . content . type || "text" )
52+ } ">${ escapeXml ( item . content . body ) } </content:encoded>\n`
53+ : "" ;
54+ return (
55+ ` <item>\n` +
56+ ` <title>${ escapeXml ( item . title ) } </title>\n` +
57+ ` <link>${ escapeXml ( item . link ) } </link>\n` +
58+ ` <guid>${ escapeXml ( item . id ) } </guid>\n` +
59+ ` <pubDate>${ item . updated . toUTCString ( ) } </pubDate>\n` +
60+ ` <description>${ escapeXml ( item . description ) } </description>\n` +
61+ contentXml +
62+ ` </item>\n`
63+ ) ;
64+ } ) . join ( "" ) ;
65+ xmlParts . push ( itemsXml ) ;
6966
7067 xmlParts . push ( ` </channel>\n` , `</rss>\n` ) ;
7168 return xmlParts . join ( "" ) ;
0 commit comments