UNPKG

rsshub

Version:
53 lines (51 loc) 1.76 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as md5 } from "./md5-C8GRvctM.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; import { load } from "cheerio"; //#region lib/routes/crush/index.ts const baseUrl = "https://www.crush.ninja"; const route = { path: "/pages/:id", name: "匿名投稿頁面", url: "www.crush.ninja", maintainers: ["Tsuyumi25"], example: "/crush/pages/141719909033861", parameters: { id: { description: "頁面 ID 或代稱,例如 `141719909033861` 或 `awkward87poland`" } }, radar: [{ source: ["www.crush.ninja/:locale/pages/:id"], target: "/pages/:id" }], handler }; async function handler(ctx) { const { id } = ctx.req.param(); const targetUrl = `${baseUrl}/en-us/pages/${id}/`; const $ = load(await ofetch_default(targetUrl)); const title = $("meta[property=\"og:title\"]").attr("content") || `CrushNinja - ${id}`; const description = $("meta[name=\"description\"]").attr("content") ?? void 0; const image = $("meta[property=\"og:image\"]").attr("content") ?? void 0; return { title, description, link: targetUrl, item: $("div.rounded-border").toArray().map((el) => { const $el = $(el); const description$1 = ($el.find(".p-1").first().text() || "").trim(); return { title: description$1, description: description$1, pubDate: timezone(parseDate(($el.children("div").last().text() || "").trim().replace("Published at: ", "")), 0), guid: `${targetUrl}#${md5(description$1)}` }; }), image, allowEmpty: true }; } //#endregion export { route };