Skip to content

Commit

Permalink
feat(route): introduce /raycast/changelog (#16017)
Browse files Browse the repository at this point in the history
  • Loading branch information
equt authored Jun 28, 2024
1 parent 762bae1 commit 811f02e
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
54 changes: 54 additions & 0 deletions lib/routes/raycast/changelog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import type { Route, DataItem } from '@/types';
import ofetch from '@/utils/ofetch';
import cache from '@/utils/cache';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';

const handler: Route['handler'] = async () => {
const item = (await cache.tryGet('raycast:changelog', async () => {
const data = await ofetch('https://www.raycast.com/changelog');

const $ = load(data);

return $('article')
.toArray()
.map<DataItem>((item) => {
const $ = load(item);

const version = $('span[id]').attr('id');
const html = $('div.markdown').html() ?? '';
const date = $('span[class^=ChangelogEntry_changelogDate]').text().trim();

return {
title: `Version ${version}`,
description: html,
link: `https://www.raycast.com/changelog/${version?.replaceAll('.', '-')}`,
pubDate: parseDate(date),
};
});
})) as DataItem[];

return {
title: 'Raycast Changelog',
link: 'https://www.raycast.com/changelog',
language: 'en-US',
item,
};
};

export const route: Route = {
path: '/changelog',
name: 'Changelog',
categories: ['program-update'],
example: '/raycast/changelog',
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
handler,
maintainers: ['equt'],
};
7 changes: 7 additions & 0 deletions lib/routes/raycast/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: 'Raycast',
url: 'raycast.com',
categories: ['program-update'],
};

0 comments on commit 811f02e

Please sign in to comment.