rsshub
Version:
Make RSS Great Again!
53 lines (51 loc) • 1.79 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import { t as logger_default } from "./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/enterprisecraftsmanship/index.ts
const route = {
path: "/archives",
categories: ["blog"],
example: "/enterprisecraftsmanship/archives",
radar: [{ source: ["enterprisecraftsmanship.com/archives/"] }],
url: "enterprisecraftsmanship.com/",
name: "Archives",
maintainers: ["liyaozhong"],
handler,
description: "Enterprise Craftsmanship blog archives"
};
async function handler() {
const currentUrl = `https://enterprisecraftsmanship.com/archives`;
const $ = load((await got_default(currentUrl)).data);
let items = $(".postIndexItem").toArray().map((item) => {
const $item = $(item);
return {
title: $item.find(".title a").text().trim(),
link: new URL($item.find(".title a").attr("href"), currentUrl).href,
pubDate: parseDate($item.find(".date").text().trim())
};
});
items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => {
try {
const $detail = load((await got_default(item.link)).data);
item.description = ($detail(".post > .paragraph").html() ?? "") + ($detail(".post >.sect1").html() ?? "");
return item;
} catch (error) {
logger_default.error(`处理文章 ${item.link} 时发生错误: ${error}`);
return item;
}
})));
return {
title: "Enterprise Craftsmanship - Archives",
link: currentUrl,
item: items
};
}
//#endregion
export { route };