UNPKG

rsshub

Version:
43 lines (42 loc) 1.24 kB
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/ui.cn/article.ts const route = { path: "/article", categories: ["design"], example: "/ui.cn/article", name: "推荐文章", maintainers: ["WenryXu"], handler }; async function handler() { const baseUrl = "https://www.ui.cn"; const $ = load(await rofetch(`${baseUrl}/`)); const list = $("#article .h-article-list li").toArray().map((item) => { const a = $(item).find(".ellipsis"); const link = baseUrl + a.attr("href"); return { title: a.text(), link, guid: link }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const $detail = load(await rofetch(item.link)); return { ...item, description: $detail(".exp-content").html(), pubDate: timezone(parseDate($detail(".works-top .time em").text().replaceAll("更新于:", "")), 8) }; }))); return { title: "推荐文章 - UI 中国", link: `${baseUrl}/`, item: items }; } //#endregion export { route };