UNPKG

rsshub

Version:
60 lines (58 loc) 2.02 kB
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as art } from "./render-BQo6B4tL.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { n as viewForum, r as viewThread } from "./query-BWAtKkTV.mjs"; import path from "node:path"; //#region lib/routes/lkong/forum.ts init_esm_shims(); const route = { path: "/forum/:id?/:digest?", radar: [{ source: ["lkong.com/forum/:id", "lkong.com/"] }], name: "Unknown", maintainers: ["nczitzk", "ma6254"], handler }; async function handler(ctx) { const id = ctx.req.param("id") ?? "8"; const digest = ctx.req.param("digest"); const rootUrl = "https://www.lkong.com"; const apiUrl = "https://api.lkong.com/api"; const currentUrl = `${rootUrl}/forum/${id}`; const response = await got_default({ method: "post", url: apiUrl, json: viewForum(id) }); let items = response.data.data[digest ? "hots" : "threads"].map((item) => ({ guid: item.tid, title: item.title, link: `${rootUrl}/thread/${item.tid}` })); items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => { const detailResponse = await got_default({ method: "post", url: apiUrl, json: viewThread(item.guid, 1) }); item.author = detailResponse.data.data.thread?.author.name; item.pubDate = parseDate(detailResponse.data.data.thread?.dateline); item.description = art(path.join(__dirname, "templates/content-b0aebebb.art"), { content: JSON.parse(detailResponse.data.data.posts[0].content) }); delete item.guid; return item; }))); return { title: `${response.data.data.forum.name} - 龙空`, link: currentUrl, item: items, description: response.data.data.forumCount.info }; } //#endregion export { route };