rsshub
Version:
Make RSS Great Again!
45 lines (44 loc) • 1.29 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 timezone } from "./timezone-UiMFOuvL.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 response = await rofetch(`${baseUrl}/`);
const $ = load(response);
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 = await rofetch(item.link);
const $detail = load(detail);
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 };