rss in ejs

This commit is contained in:
2025-07-23 02:38:03 +01:00
parent ff1d34a7ab
commit 306adf3943
2 changed files with 26 additions and 24 deletions

View File

@@ -69,31 +69,13 @@ app.get(config.rss_url, (req,res) => {
})
}
else {
let rss_content = `<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>${config.site_name}</title>
<link>${config.site_url}</link>
<description>${config.site_description}</description>
`
for (let i = posts.length-1; i >= 0; i--) {
rss_content += `
<item>
<title>${posts[i]["title"]}</title>
<link>${config.site_url}/post/${i}</link>
<description><![CDATA[${converter.makeHtml(posts[i]["content"])}]]></description>
<guid isPermaLink="true">${config.site_url}/post/${i}</guid>
<pubDate>${func.unix_time_to_rss_date(posts[i]['pubdate'])}</pubDate>`
for (let j = 0; j < posts[i]['tags'].length; j++) {
rss_content += `<category><![CDATA[${posts[i]['tags'][j]}]]></category>`
};
rss_content += "</item>"
}
rss_content += `
</channel>
</rss>`
res.setHeader('content-type', 'application/rss+xml');
res.send(rss_content)
res.render("syndication/rss", {
config,
posts,
converter,
func,
})
};
});