UNPKG

rsshub

Version:
40 lines (39 loc) 1.18 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as parseDate } from "./parse-date-CjhZE69i.mjs"; import { load } from "cheerio"; //#region lib/routes/rescuetime/release-notes.ts const route = { path: "/release-notes/:os?", categories: ["program-update"], example: "/rescuetime/release-notes", parameters: { os: "OS id, see below" }, name: "Release Notes", maintainers: ["nczitzk"], description: `| Mac OS | Windows | | ------ | ------- | | mac | windows |`, handler }; async function handler(ctx) { const { os = "mac" } = ctx.req.param(); const currentUrl = `https://www.rescuetime.com/release-notes/${os}`; const $ = load((await rofetch(currentUrl)).replaceAll("<h3 align=\"left\">", "</content><content><h3 align=\"left\">")); const items = $(".release").toArray().map((item) => { const $item = $(item); const title = $item.find("h2").text(); $item.find("h2").remove(); return { title, link: currentUrl, description: $item.html(), pubDate: parseDate(title.match(/(\d{4}(?:\/\d{2}){2})/)[1], "YYYY/MM/DD") }; }); return { title: $("h1").text(), link: currentUrl, item: items }; } //#endregion export { route };