This repository has been archived on 2024-02-11. You can view files and clone it, but cannot push or open issues or pull requests.
sitio/feeds.js

37 lines
1,020 B
JavaScript
Raw Normal View History

2023-11-12 09:37:38 +00:00
const { readFile, writeFile } = require("fs/promises");
const { join } = require("path");
2023-04-16 23:40:10 +00:00
2023-11-12 09:37:38 +00:00
const feeds = {
2023-04-16 23:40:10 +00:00
fauno: "https://fauno.endefensadelsl.org/feed.xml",
copiona: "https://copiona.com/feed.xml",
j3s: "https://j3s.sh/feed.atom",
2023-04-30 19:09:38 +00:00
// icyphox: "https://icyphox.sh/blog/feed.xml",
2023-05-04 12:08:13 +00:00
brunoscheufler: "https://brunoscheufler.com/rss.xml",
2023-09-01 19:35:24 +00:00
taylor: "https://taylor.town/feed.xml",
2023-12-26 20:40:53 +00:00
nexxel: "https://www.nexxel.dev/rss.xml",
2023-04-16 23:40:10 +00:00
};
if (process.argv[2] === "refresh") {
2023-11-12 09:37:38 +00:00
(async () => {
await Promise.all(
Object.entries(feeds).map(async ([name, url]) => {
console.log(`Refreshing ${name}`);
const res = await fetch(url);
const txt = await res.text();
await writeFile(join("cached-feeds/", `${name}.xml`), txt);
2023-12-26 20:40:53 +00:00
}),
2023-11-12 09:37:38 +00:00
);
})();
2023-04-16 23:40:10 +00:00
}
/**
* Lee un feed ya cacheado sin parsear.
* @param {string} name
* @returns string
*/
2023-11-12 09:37:38 +00:00
async function readFeed(name) {
2023-04-16 23:40:10 +00:00
return await readFile(join("cached-feeds/", name + ".xml"), "utf-8");
}
2023-11-12 09:37:38 +00:00
module.exports = { feeds, readFeed };