rsshub
Version:
Make RSS Great Again!
47 lines (45 loc) • 1.4 kB
JavaScript
import "./dist-Bog6z_OM.mjs";
import "./config-MQ-7ebJ_.mjs";
import "./logger-C4avouvV.mjs";
import { t as ofetch_default } from "./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 { t as rss_parser_default } from "./rss-parser-Cnh4NKwh.mjs";
import { load } from "cheerio";
//#region lib/routes/baoyu/index.ts
const route = {
path: "/blog",
categories: ["blog"],
example: "/baoyu/blog",
radar: [{ source: ["baoyu.io/"] }],
url: "baoyu.io/",
name: "Blog",
maintainers: ["liyaozhong", "Circloud"],
handler,
description: "宝玉 - 博客文章"
};
async function handler() {
const rootUrl = "https://baoyu.io";
const response = await ofetch_default(`${rootUrl}/feed.xml`);
const feed = await rss_parser_default.parseString(response);
return {
title: "宝玉的博客",
link: rootUrl,
item: await Promise.all(feed.items.map((item) => {
const link = item.link;
return cache_default.tryGet(link, async () => {
const content = load(await ofetch_default(link))(".container").find(".prose").html() || "";
return {
title: item.title,
description: content,
link,
pubDate: item.pubDate ? parseDate(item.pubDate) : void 0,
author: item.creator || "宝玉"
};
});
}))
};
}
//#endregion
export { route };