UNPKG

rsshub

Version:
66 lines (64 loc) 2.14 kB
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs"; import { t as config } from "./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 path from "node:path"; import { load } from "cheerio"; import markdownit from "markdown-it"; //#region lib/routes/hellogithub/volume.ts init_esm_shims(); const md = markdownit({ html: true }); art.defaults.imports.render = function(string) { return md.render(string); }; const route = { path: "/volume", example: "/hellogithub/volume", name: "月刊", maintainers: [ "moke8", "nczitzk", "CaoMeiYouRen" ], handler }; async function handler(ctx) { const limit = Number.parseInt(ctx.req.query("limit")) || 10; const rootUrl = "https://hellogithub.com"; const volumes = (await got_default({ method: "get", url: "https://api.hellogithub.com/v1/periodical/" })).data.volumes.slice(0, limit); return { title: "HelloGithub - 月刊", link: "https://hellogithub.com/periodical", item: await Promise.all(volumes.map(async (volume) => { const current = volume.num; const lastmod = volume.lastmod; const currentUrl = `${rootUrl}/periodical/volume/${current}`; const key = `hellogithub:${currentUrl}`; return await cache_default.tryGet(key, async () => { const text = load((await got_default({ method: "get", url: currentUrl })).data)("#__NEXT_DATA__").text(); const data = JSON.parse(text).props; const id = data.pageProps.volume.current_num; return { title: `《HelloGitHub》第 ${id} 期`, link: `${rootUrl}/periodical/volume/${id}`, description: art(path.join(__dirname, "templates/volume-87813149.art"), { data: data.pageProps.volume.data }), pubDate: parseDate(lastmod) }; }, config.cache.routeExpire, false); })) }; } //#endregion export { route };