UNPKG

rsshub

Version:
67 lines (65 loc) 2.05 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import { t as ViewType } from "./types-gOySfSXJ.mjs"; import "./logger-C4avouvV.mjs"; import { t as ofetch_default } from "./ofetch-DKl_Ma9g.mjs"; import { t as parseDate } from "./parse-date-r5WDWHno.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 };