rsshub
Version:
Make RSS Great Again!
42 lines (41 loc) • 1.3 kB
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { t as parseDate } from "./parse-date-CjhZE69i.mjs";
import { t as cache_default } from "./cache-CiDoUSLo.mjs";
import { t as timezone } from "./timezone-DE--ze1V.mjs";
import { load } from "cheerio";
//#region lib/routes/socialbeta/home.ts
const route = {
path: "/home",
categories: ["new-media"],
example: "/socialbeta/home",
name: "首页",
maintainers: ["nczitzk"],
handler
};
async function handler() {
const currentUrl = "https://socialbeta.com/";
const $ = load(await rofetch(currentUrl));
const list = $(".list .tit a").toArray().map((item) => {
const a = $(item);
return {
title: a.text(),
link: a.attr("href")
};
});
const uniqueList = new Map(list.map((item) => [item.link, item])).values().toArray().slice(0, 15);
return {
title: "SocialBeta - 首页",
link: currentUrl,
item: await Promise.all(uniqueList.map((item) => cache_default.tryGet(item.link, async () => {
const content = load(await rofetch(item.link));
const date = content(".info_cam, .info_art, .head_zt_right").text().match(/\d{4}-\d{2}-\d{2}/)?.[0];
return {
...item,
pubDate: date ? timezone(parseDate(date), 8) : void 0,
description: content("div.content").html()
};
})))
};
}
//#endregion
export { route };