UNPKG

rsshub

Version:
68 lines (66 loc) 2.09 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import { t as ViewType } from "./types-D84BRIt4.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 { load } from "cheerio"; //#region lib/routes/cursor/blog.ts const handler = async (ctx) => { const { topic } = ctx.req.param(); const limit = Number.parseInt(ctx.req.query("limit") ?? "10", 10); const baseUrl = "https://cursor.com"; const path = topic ? `/blog/topic/${topic}` : "/blog"; const targetUrl = new URL(path, baseUrl).href; const $ = load(await ofetch_default(targetUrl, { headers: { cookie: "NEXT_LOCALE=en" } })); const items = $("#main").last().find("article").slice(0, limit).toArray().map((el) => { const $el = $(el); const $link = $el.find("a").first(); const title = $link.find("p").first().text().trim(); const description = $link.find("p").eq(1).text().trim(); const pubDate = parseDate($el.find("time").first().text().trim()); const href = $link.attr("href"); return { title, description, pubDate, link: href ? new URL(href, baseUrl).href : void 0 }; }); return { title: $("title").text() || "Cursor Blog", description: $("meta[property=\"og:description\"]").attr("content"), link: targetUrl, item: items, allowEmpty: true, image: $("meta[property=\"og:image\"]").attr("content") }; }; const route = { path: "/blog/:topic?", name: "Blog", url: "cursor.com", maintainers: ["johan456789"], example: "/cursor/blog", parameters: { topic: "Optional topic: product | research | company | news" }, description: void 0, categories: ["blog"], features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportRadar: true, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["cursor.com/blog", "cursor.com/blog/topic/:topic"], target: "/blog/:topic" }], view: ViewType.Articles, handler }; //#endregion export { handler, route };