rsshub
Version:
Make RSS Great Again!
81 lines (75 loc) • 2.56 kB
JavaScript
import "./dist-Bog6z_OM.mjs";
import "./config-MQ-7ebJ_.mjs";
import "./logger-C4avouvV.mjs";
import "./ofetch-DKl_Ma9g.mjs";
import { t as parseDate } from "./parse-date-r5WDWHno.mjs";
import "./is-worker-DESPicPc.mjs";
import { t as cache_default } from "./cache-SV6W5EPy.mjs";
import "./helpers-Bo4JQYdN.mjs";
import { t as got_default } from "./got-CO-ndVl2.mjs";
import { load } from "cheerio";
//#region lib/routes/nodejs/blog.ts
const route = {
path: "/blog/:language?",
categories: ["programming"],
example: "/nodejs/blog",
parameters: { language: "Language, see below, en by default" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["nodejs.org/:language/blog", "nodejs.org/"] }],
name: "News",
maintainers: ["nczitzk"],
handler,
description: `Official RSS Source: https://nodejs.org/en/feed/blog.xml
| العربية | Catalan | Deutsch | Español | زبان فارسی |
| ------- | ------- | ------- | ------- | ---------- |
| ar | ca | de | es | fa |
| Français | Galego | Italiano | 日本語 | 한국어 |
| -------- | ------ | -------- | ------ | ------ |
| fr | gl | it | ja | ko |
| Português do Brasil | limba română | Русский | Türkçe | Українська |
| ------------------- | ------------ | ------- | ------ | ---------- |
| pt-br | ro | ru | tr | uk |
| 简体中文 | 繁體中文 |
| -------- | -------- |
| zh-cn | zh-tw |`
};
async function handler(ctx) {
const language = ctx.req.param("language") ?? "en";
const rootUrl = "https://nodejs.org";
const currentUrl = `${rootUrl}/${language}/blog`;
let items = load((await got_default({
method: "get",
url: currentUrl
})).data)("article").toArray().map((article) => {
const $article = load(article);
const author = $article("footer p").text();
const pubDate = parseDate($article("footer time").attr("datetime"));
return {
title: $article("a[aria-label]").prop("aria-label"),
link: `${rootUrl}${$article("a[aria-label]").attr("href")}`,
author,
pubDate
};
});
items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => {
item.description = load((await got_default({
method: "get",
url: item.link
})).data)("main").html();
return item;
})));
return {
title: "News - Node.js",
link: currentUrl,
item: items
};
}
//#endregion
export { route };