rsshub
Version:
Make RSS Great Again!
43 lines (42 loc) • 1.25 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 { t as parser } from "./rss-parser-Dx_OGbNh.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 rofetch(`${rootUrl}/feed.xml`);
const feed = await parser.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 response = await rofetch(link);
const content = load(response)(".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 };