From cc1d43c297bd65e6a85673ff41d967bc23c82ba8 Mon Sep 17 00:00:00 2001 From: L <92271804+jean-jacket@users.noreply.github.com> Date: Sat, 19 Jul 2025 11:03:29 +0100 Subject: [PATCH] feat(route): add Apple design updates (#19639) * feat(route): add Apple design updates * fix: update example URL in route * refactor: remove cache --- lib/routes/apple/design.ts | 52 +++++++++++++++++++++++++++++++++++ lib/routes/apple/namespace.ts | 2 +- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 lib/routes/apple/design.ts diff --git a/lib/routes/apple/design.ts b/lib/routes/apple/design.ts new file mode 100644 index 000000000..1e70c78c3 --- /dev/null +++ b/lib/routes/apple/design.ts @@ -0,0 +1,52 @@ +import { Route } from '@/types'; +import { parseDate } from '@/utils/parse-date'; +import ofetch from '@/utils/ofetch'; +import { load } from 'cheerio'; + +export const route: Route = { + categories: ['design'], + example: '/apple/design', + handler, + maintainers: ['jean-jacket'], + name: 'Design updates', + path: '/design', + url: 'developer.apple.com/design/whats-new/', +}; + +async function handler() { + const LINK = 'https://developer.apple.com/design/whats-new/'; + + const response = await ofetch(LINK); + const $ = load(response); + + const items = $('table') + .toArray() + .flatMap((item) => { + const table = $(item); + const date = table.find('.date').first().text(); + + return table + .find('.topic-item') + .toArray() + .map((row) => { + const update = $(row); + const titleTag = update.find('span.topic-title a'); + const title = titleTag.text(); + const link = `https://developer.apple.com${titleTag.attr('href')}`; + const description = update.find('span.description').text(); + + return { + description, + link, + pubDate: parseDate(date), + title, + }; + }); + }); + + return { + item: items, + link: LINK, + title: 'Apple design updates', + }; +} diff --git a/lib/routes/apple/namespace.ts b/lib/routes/apple/namespace.ts index 4f9fd1816..7539f7966 100644 --- a/lib/routes/apple/namespace.ts +++ b/lib/routes/apple/namespace.ts @@ -2,6 +2,6 @@ import type { Namespace } from '@/types'; export const namespace: Namespace = { name: 'Apple', - url: 'apps.apple.com', + url: 'apple.com', lang: 'en', };