rsshub
Version:
Make RSS Great Again!
46 lines (45 loc) • 1.26 kB
JavaScript
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs";
import { t as parseDate } from "./parse-date-3kcy2Eau.mjs";
import { t as cache_default } from "./cache-C1Y-9qDV.mjs";
import { load } from "cheerio";
//#region lib/routes/react/blog.ts
const handler = async () => {
const data = await rofetch("https://react.dev/blog");
const $ = load(data);
return {
title: "React Blog",
link: "https://react.dev/blog",
language: "en-us",
item: await Promise.all($("a[href^=\"/blog/\"]").toArray().slice(0, 20).map((item) => {
const link = `https://react.dev${item.attribs.href}`;
return cache_default.tryGet(`react:blog:${link}`, async () => {
const data = await rofetch(link);
const $ = load(data);
return {
title: $("h1").first().text(),
link,
description: $("article div:nth-child(2)").html(),
pubDate: parseDate($("p.whitespace-pre-wrap").first().text().split(/\s+by/, 1)[0])
};
});
}))
};
};
const route = {
path: "/blog",
name: "Blog",
categories: ["blog"],
maintainers: ["equt"],
example: "/react/blog",
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
handler
};
//#endregion
export { route };