From a89d26e5ea653e4ed91544cf03b573f7fea22408 Mon Sep 17 00:00:00 2001 From: Tsung-Han Yu <14802181+johan456789@users.noreply.github.com> Date: Tue, 12 Aug 2025 02:10:34 +0800 Subject: [PATCH] feat(route): Add RSS feed for MIT HAN Lab Blog (#19795) * feat: Add RSS feed for MIT HAN Lab Blog - add a new RSS feed for the MIT HAN Lab blog (https://hanlab.mit.edu/blog), available at the route `/mit/hanlab/blog`. - include the title, link, date, and a TL;DR snippet for each post. * Update lib/routes/mit/hanlab.ts --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- lib/routes/mit/hanlab.ts | 61 +++++++++++++++++++++++++++++++++++++ lib/routes/mit/namespace.ts | 6 ++++ 2 files changed, 67 insertions(+) create mode 100644 lib/routes/mit/hanlab.ts create mode 100644 lib/routes/mit/namespace.ts diff --git a/lib/routes/mit/hanlab.ts b/lib/routes/mit/hanlab.ts new file mode 100644 index 000000000..fc0c21da0 --- /dev/null +++ b/lib/routes/mit/hanlab.ts @@ -0,0 +1,61 @@ +import { Route } from '@/types'; +import got from '@/utils/got'; +import { parseDate } from '@/utils/parse-date'; +import { load } from 'cheerio'; + +export const route: Route = { + path: '/hanlab/blog', + categories: ['blog'], + example: '/mit/hanlab/blog', + parameters: {}, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['hanlab.mit.edu/blog'], + }, + ], + name: 'HAN Lab Blog', + maintainers: ['johan456789'], + handler, + description: 'MIT HAN Lab pioneers research in efficient AI, advancing algorithms and hardware to make generative models faster, smarter, and more accessible.', +}; + +async function handler() { + const rootUrl = 'https://hanlab.mit.edu'; + const currentUrl = `${rootUrl}/blog`; + + const response = await got(currentUrl); + const $ = load(response.data); + + const items = $('a.post-card-wrapper') + .toArray() + .map((item) => { + const el = $(item); + const titleEl = el.find('h3.text-title'); + const title = titleEl.text().trim(); + const link = new URL(el.attr('href') ?? '', rootUrl).href; + const description = el.find('p.text-tldr').html() ?? undefined; + const dateText = el.find('div.text-date').text().trim(); + const pubDate = parseDate(dateText); + + return { + title, + link, + description, + pubDate, + }; + }); + + return { + title: 'MIT HAN Lab Blog', + link: currentUrl, + item: items, + }; +} diff --git a/lib/routes/mit/namespace.ts b/lib/routes/mit/namespace.ts new file mode 100644 index 000000000..ed3b24124 --- /dev/null +++ b/lib/routes/mit/namespace.ts @@ -0,0 +1,6 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'Massachusetts Institute of Technology', + url: 'mit.edu', +};