UNPKG

rsshub

Version:
61 lines (59 loc) 1.83 kB
import "./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 got_default } from "./got-KxxWdaxq.mjs"; import { load } from "cheerio"; //#region lib/routes/konghq/blog-posts.ts const BASE_URL = "https://konghq.com"; const BLOG_POSTS_URL = `${BASE_URL}/blog`; const route = { path: "/blog-posts", categories: ["programming"], example: "/konghq/blog-posts", parameters: {}, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["konghq.com/blog/*"] }], name: "博客最新文章", maintainers: ["piglei"], handler, url: "konghq.com/blog/*" }; async function handler() { const { data: response } = await got_default(`${BLOG_POSTS_URL}/page/1`); const $ = load(response); const posts = JSON.parse($("#__NEXT_DATA__").text()).props.pageProps.cardsPaged.cards.map((item) => { const title = item.title; const author = item.authors.map((author$1) => author$1.title).join(", "); const category = item.term.title; return { title, link: `${BASE_URL}${item.link.href}`, pubDate: parseDate(item.publishedAt), author, category }; }); return { title: `Kong Inc(konghq.com) blog posts`, link: BLOG_POSTS_URL, item: await Promise.all(posts.map((item) => cache_default.tryGet(item.link, async () => { const { data: response$1 } = await got_default(item.link); item.description = load(response$1)("section[class^=\"blog_sections\"]").first().html(); return item; }))) }; } //#endregion export { route };