UNPKG

rsshub

Version:
93 lines (91 loc) 2.74 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/changelog.ts const handler = async (ctx) => { const limit = Number.parseInt(ctx.req.query("limit") ?? "100", 10); const baseUrl = "https://cursor.com"; const targetUrl = new URL("changelog", baseUrl).href; const $ = load(await ofetch_default(targetUrl, { headers: { cookie: "NEXT_LOCALE=en" } })); const language = $("html").attr("lang") ?? "en"; const items = $("article.relative").slice(0, limit).toArray().map((el) => { const $el = $(el); let version = ""; let pubDateStr; $el.find("div").each((_, div) => { const dateVersionMatch = $(div).text().trim().match(/^(\w+\s+\d{1,2},\s+\d{4})(\d+\.\d+)$/); if (dateVersionMatch) { pubDateStr = dateVersionMatch[1]; version = dateVersionMatch[2]; return false; } }); const linkEl = $el.find("a[href^=\"/changelog/\"]").first(); const titleText = linkEl.length ? linkEl.text().trim() : $el.find("h2").first().text().trim(); const title = version ? `[${version}] ${titleText}` : titleText; const linkUrl = linkEl.attr("href"); const guid = `cursor-changelog-${version || "unknown"}`; const upDatedStr = pubDateStr; const $h2El = $el.find("h2").first(); if ($h2El.length) { $h2El.prevAll().remove(); $h2El.remove(); } const description = $el.html() || ""; return { title, description, pubDate: pubDateStr ? parseDate(pubDateStr) : void 0, link: linkUrl ? new URL(linkUrl, baseUrl).href : void 0, guid, id: guid, content: { html: description, text: description }, updated: upDatedStr ? parseDate(upDatedStr) : void 0, language }; }); return { title: $("title").text(), description: $("meta[property=\"og:description\"]").attr("content"), link: targetUrl, item: items, allowEmpty: true, image: $("meta[property=\"og:image\"]").attr("content"), language }; }; const route = { path: "/changelog", name: "Changelog", url: "cursor.com", maintainers: ["p3psi-boo", "nczitzk"], handler, example: "/cursor/changelog", parameters: void 0, description: void 0, categories: ["program-update"], features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportRadar: true, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["cursor.com/changelog"], target: "/changelog" }], view: ViewType.Articles }; //#endregion export { handler, route };