diff --git a/src/server.js b/src/server.js index f653a12..998d304 100644 --- a/src/server.js +++ b/src/server.js @@ -69,31 +69,13 @@ app.get(config.rss_url, (req,res) => { }) } else { - let rss_content = ` - - - ${config.site_name} - ${config.site_url} - ${config.site_description} - ` - for (let i = posts.length-1; i >= 0; i--) { - rss_content += ` - - ${posts[i]["title"]} - ${config.site_url}/post/${i} - - ${config.site_url}/post/${i} - ${func.unix_time_to_rss_date(posts[i]['pubdate'])}` - for (let j = 0; j < posts[i]['tags'].length; j++) { - rss_content += `` - }; - rss_content += "" - } - rss_content += ` - - ` res.setHeader('content-type', 'application/rss+xml'); - res.send(rss_content) + res.render("syndication/rss", { + config, + posts, + converter, + func, + }) }; }); diff --git a/views/syndication/rss.ejs b/views/syndication/rss.ejs new file mode 100644 index 0000000..73e43e6 --- /dev/null +++ b/views/syndication/rss.ejs @@ -0,0 +1,20 @@ +" ?> + + + <%= config.site_name %> + <%= config.site_url %> + <%= config.site_description %> + <% for (let postID = posts.length-1; postID >= 0; postID--) { %> + + <%= posts[postID]["title"] %> + <%= config.site_url %>/post/<%= postID %> + ]]> + <%= config.site_url %>/post/<%= postID %> + <%= func.unix_time_to_rss_date(posts[postID]['pubdate']) %> + <% for (let tag_index = 0; tag_index < posts[postID]['tags'].length; tag_index++) { %> + ]]> + <% } %> + + <% } %> + +