diff --git a/lib/routes/kovidgoyal/kitty/changelog.ts b/lib/routes/kovidgoyal/kitty/changelog.ts new file mode 100644 index 000000000..983acbb11 --- /dev/null +++ b/lib/routes/kovidgoyal/kitty/changelog.ts @@ -0,0 +1,83 @@ +import { Route } from '@/types'; +import ofetch from '@/utils/ofetch'; +import { load } from 'cheerio'; +import { parseDate } from '@/utils/parse-date'; + +export const route: Route = { + path: '/kitty/changelog', + categories: ['program-update'], + example: '/kovidgoyal/kitty/changelog', + parameters: {}, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['sw.kovidgoyal.net/kitty/changelog/'], + target: '/kitty/changelog', + }, + ], + name: 'Changelog', + maintainers: ['xbot'], + handler, + url: 'sw.kovidgoyal.net/kitty/changelog/', +}; + +async function handler() { + const url = 'https://sw.kovidgoyal.net/kitty/changelog/'; + const response = await ofetch(url); + const $ = load(response); + + // Find the "Detailed list of changes" section + const detailedSection = $('#detailed-list-of-changes'); + + const items = detailedSection + .find('section[id^="id"]') + .toArray() + .map((section) => { + const $section = $(section); + + // Extract version and date from h3 title + const titleText = $section.find('h3').first().text().trim(); + const versionMatch = titleText.match(/^([\d.]+)\s*\[([^\]]+)\]/); + + if (!versionMatch) { + return null; + } + + const version = versionMatch[1]; + const dateStr = versionMatch[2]; + + // Extract changelog items from the ul list + const changelogItems = $section + .find('ul.simple li') + .toArray() + .map((li) => $(li).html()) + .filter(Boolean); + + // Create description from changelog items + const description = changelogItems.length > 0 ? '