* fix: add back route metadata * fix: update route handlers to use ctx.req.param for path retrieval * fix: add back route metadata for tsx * fix: remove unnecessary reposition * fix: remove * path * docs: fix route name * fix: radar url * fix: more maintainers * fix: typo * fix: last batch of empty maintainers * feat!: remove biodiscover * fix: correct eslint directive in data258 route
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { load } from 'cheerio';
|
|
|
|
import type { Route } from '@/types';
|
|
import got from '@/utils/got';
|
|
import { parseDate } from '@/utils/parse-date';
|
|
|
|
const platformSlugs = {
|
|
desktop: 'releasenotes',
|
|
beta: 'beta/notes',
|
|
nightly: 'nightly/notes',
|
|
android: 'android/releasenotes',
|
|
ios: 'ios/notes',
|
|
};
|
|
|
|
export const route: Route = {
|
|
path: '/release/:platform?',
|
|
categories: ['program-update'],
|
|
example: '/firefox/release/desktop',
|
|
parameters: { platform: 'the platform' },
|
|
description: `| Desktop | Android | Beta | Nightly | iOS |
|
|
| ------- | ------- | ---- | ------- | --- |
|
|
| desktop | android | beta | nightly | ios |`,
|
|
name: 'New Release',
|
|
maintainers: ['fengkx'],
|
|
handler,
|
|
};
|
|
|
|
async function handler(ctx) {
|
|
const { platform = 'desktop' } = ctx.req.param();
|
|
const devicePlatform = platform.replace('-', '/');
|
|
|
|
const link = ['https://www.mozilla.org/en-US/firefox', Object.hasOwn(platformSlugs, devicePlatform) ? platformSlugs[devicePlatform] : devicePlatform].filter(Boolean).join('/');
|
|
const response = await got.get(link);
|
|
const $ = load(response.data);
|
|
const version = $('.c-release-version').text();
|
|
const pubDate = parseDate($('.c-release-date').text(), 'MMMM D, YYYY');
|
|
|
|
return {
|
|
title: `Firefox ${platform} release notes`,
|
|
link,
|
|
item: [
|
|
{
|
|
title: `Firefox ${platform} ${version} release notes`,
|
|
link,
|
|
description: $('.c-release-notes').html(),
|
|
guid: `${platform} ${version}`,
|
|
pubDate,
|
|
},
|
|
],
|
|
};
|
|
}
|