UNPKG

rsshub

Version:
68 lines (66 loc) 2.52 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import "./ofetch-DKl_Ma9g.mjs"; import { n as parseRelativeDate, t as parseDate } from "./parse-date-r5WDWHno.mjs"; import "./helpers-Bo4JQYdN.mjs"; import { t as got_default } from "./got-CO-ndVl2.mjs"; import { t as timezone } from "./timezone-CA9Huotp.mjs"; import { Fragment, jsx, jsxs } from "hono/jsx/jsx-runtime"; import { load } from "cheerio"; import { renderToString } from "hono/jsx/dom/server"; //#region lib/routes/qidian/author.tsx const route = { path: "/author/:id", categories: ["reading"], example: "/qidian/author/9639927", parameters: { id: "作者 id, 可在作者页面 URL 找到" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["my.qidian.com/author/:id"] }], name: "作者", maintainers: ["miles170"], handler }; async function handler(ctx) { const currentUrl = `https://my.qidian.com/author/${ctx.req.param("id")}/`; const $ = load((await got_default(currentUrl)).data); const authorName = $(".header-msg h1").contents().first().text().trim(); const items = $(".author-work .author-item").toArray().map((item) => { item = $(item); const messageItem = item.find(".author-item-msg"); const updatedDate = messageItem.find(".author-item-update span").text().replace("·", "").trim(); return { title: messageItem.find(".author-item-title").text().trim(), author: authorName, category: messageItem.find(".author-item-exp a").first().text().trim(), description: renderDescription(messageItem.find(".author-item-update a").attr("title"), item.find("a img").attr("src")), pubDate: timezone(/(今|昨)/.test(updatedDate) ? parseRelativeDate(updatedDate) : parseDate(updatedDate, "YYYY-MM-DD HH:mm"), 8), link: messageItem.find(".author-item-update a").attr("href") }; }); return { title: `${authorName} - 起点中文网`, description: $(".header-msg-desc").text().trim(), link: currentUrl, item: items }; } const renderDescription = (description, image, author) => renderToString(/* @__PURE__ */ jsx(QidianDescription, { description, image, author })); const QidianDescription = ({ description, image, author }) => /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsx("p", { children: description }), image ? /* @__PURE__ */ jsx("img", { src: image }) : null, author ?? null ] }); //#endregion export { route };