Skip to content

Commit a89d26e

Browse files
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>
1 parent 28d9367 commit a89d26e

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

lib/routes/mit/hanlab.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { Route } from '@/types';
2+
import got from '@/utils/got';
3+
import { parseDate } from '@/utils/parse-date';
4+
import { load } from 'cheerio';
5+
6+
export const route: Route = {
7+
path: '/hanlab/blog',
8+
categories: ['blog'],
9+
example: '/mit/hanlab/blog',
10+
parameters: {},
11+
features: {
12+
requireConfig: false,
13+
requirePuppeteer: false,
14+
antiCrawler: false,
15+
supportBT: false,
16+
supportPodcast: false,
17+
supportScihub: false,
18+
},
19+
radar: [
20+
{
21+
source: ['hanlab.mit.edu/blog'],
22+
},
23+
],
24+
name: 'HAN Lab Blog',
25+
maintainers: ['johan456789'],
26+
handler,
27+
description: 'MIT HAN Lab pioneers research in efficient AI, advancing algorithms and hardware to make generative models faster, smarter, and more accessible.',
28+
};
29+
30+
async function handler() {
31+
const rootUrl = 'https://hanlab.mit.edu';
32+
const currentUrl = `${rootUrl}/blog`;
33+
34+
const response = await got(currentUrl);
35+
const $ = load(response.data);
36+
37+
const items = $('a.post-card-wrapper')
38+
.toArray()
39+
.map((item) => {
40+
const el = $(item);
41+
const titleEl = el.find('h3.text-title');
42+
const title = titleEl.text().trim();
43+
const link = new URL(el.attr('href') ?? '', rootUrl).href;
44+
const description = el.find('p.text-tldr').html() ?? undefined;
45+
const dateText = el.find('div.text-date').text().trim();
46+
const pubDate = parseDate(dateText);
47+
48+
return {
49+
title,
50+
link,
51+
description,
52+
pubDate,
53+
};
54+
});
55+
56+
return {
57+
title: 'MIT HAN Lab Blog',
58+
link: currentUrl,
59+
item: items,
60+
};
61+
}

lib/routes/mit/namespace.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { Namespace } from '@/types';
2+
3+
export const namespace: Namespace = {
4+
name: 'Massachusetts Institute of Technology',
5+
url: 'mit.edu',
6+
};

0 commit comments

Comments
 (0)