From a5be22611e6a65425df88f59f1323e90e4e77ac0 Mon Sep 17 00:00:00 2001 From: gor_down Date: Fri, 6 Dec 2024 18:54:58 -0300 Subject: [PATCH] ahora si --- src/router/indexRouter.js | 20 ++++++++++---------- src/utils/rss.js | 4 +--- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/router/indexRouter.js b/src/router/indexRouter.js index 8963bdd..0768bbd 100644 --- a/src/router/indexRouter.js +++ b/src/router/indexRouter.js @@ -75,19 +75,19 @@ router.post('/comment', (req, res) => { router.get('/update_log/rss', async (_req, res) => { const csvData = await readCsv(thisDirectory + '/public/dynamic/sync/updates.csv') - const rssMappedUpdates = csvData.map((u, i) => { - return { + const rss = makeRss('https://lyricaltokarev.com/update_log/rss', "Update Log") + csvData.reverse().forEach((u, i) => { + rss.item({ title: "Update #" + i, description: u.description, author: "Gor Down", - pubDate: u.date, - } - }).reverse() - const rss = makeRss(rssMappedUpdates, 'https://lyricaltokarev.com/update_log/rss', "Update Log") - - res.send(rss) - - return rss + date: u.date, + url: u.link ? u.link : 'https://lyricaltokarev.com/home' + }) + }) + const xml = rss.xml({indent: true}) + res.setHeader('Content-Type', 'text/xml'); + res.send(xml) }) setInterval(() => { diff --git a/src/utils/rss.js b/src/utils/rss.js index a2bca66..f39e2b3 100644 --- a/src/utils/rss.js +++ b/src/utils/rss.js @@ -1,14 +1,12 @@ const RSS = require("rss") -function makeRss(items, feed_link, name, description, link){ +function makeRss(feed_link, name, description, link){ return new RSS({ title: `Lyrical Tokarev${name ? ` ~ ${name}` : ""}`, site_url: link ? link : "https://lyricaltokarev.com/home", feed_url: feed_link, description: description ? description : "Anime site.", managingEditor: "gor@lyricaltokarev.com (Gor Down)" - }, items).xml({ - indent: true }) }