rsshub
Version:
Make RSS Great Again!
61 lines (59 loc) • 1.9 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { load } from "cheerio";
//#region lib/routes/ceph/blog.ts
const route = {
path: "/blog/:topic?",
categories: ["blog"],
example: "/ceph/blog/a11y",
parameters: { category: "filter blog post by category, return all posts if not specified" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["ceph.io/"] }],
name: "Blog",
maintainers: ["pandada8"],
handler,
url: "ceph.io"
};
async function handler(ctx) {
const { category } = ctx.req.param();
const url = category ? `https://ceph.io/en/news/blog/category/${category}/` : "https://ceph.io/en/news/blog/";
const data = (await got_default.get(url)).data;
const $ = load(data);
const list = $("#main .section li").toArray().map((e) => {
const element = $(e);
const title = element.find("a").text().trim();
const pubDate = parseDate(element.find("time").attr("datetime"));
return {
title,
link: new URL(element.find("a").attr("href"), "https://ceph.io").href,
pubDate
};
});
return {
title: "Ceph Blog",
link: url,
item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const data$1 = (await got_default.get(item.link)).data;
const item$ = load(data$1);
item.author = item$("#main section > div:nth-child(1) span").text().trim();
item.description = item$("#main section > div:nth-child(2) > div").html();
return item;
})))
};
}
//#endregion
export { route };