rsshub
Version:
Make RSS Great Again!
35 lines (33 loc) • 1.49 kB
JavaScript
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
import { t as art } from "./render-BQo6B4tL.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import path from "node:path";
import { load } from "cheerio";
//#region lib/routes/caareviews/utils.ts
init_esm_shims();
const rootUrl = "http://www.caareviews.org";
const getList = async (url) => {
const $ = load((await got_default(url)).data);
return $("#infinite-content > div").toArray().map((item) => ({
title: $(item).find("div.title").text().trim(),
link: new URL($(item).find("div.title > em > a").attr("href"), rootUrl).href,
author: $(item).find("div.contributors").text().trim()
}));
};
const getItems = (ctx, list) => Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const $ = load((await got_default(item.link)).data);
const coverUrl = new URL($("div.cover > a").attr("href"), rootUrl).href;
const content = $("div.content.full-review").html();
item.description = art(path.join(__dirname, "templates/utils-e28a35d0.art"), {
coverUrl,
content
});
$("div.review_heading").remove();
item.pubDate = parseDate($("div.header-text > div.clearfix").text());
item.doi = $("div.crossref > a").attr("href").replace("http://dx.doi.org/", "");
return item;
})));
//#endregion
export { getList as n, rootUrl as r, getItems as t };