Skip to content

Commit

Permalink
feat(route): add Andy Pavlo Blog (DIYgod#18447)
Browse files Browse the repository at this point in the history
  • Loading branch information
mocusez authored Feb 24, 2025
1 parent 96c374f commit 94ce003
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
55 changes: 55 additions & 0 deletions lib/routes/cmu/andypavlo/blog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Route } from '@/types';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';

async function getArticles() {
const url = 'https://www.cs.cmu.edu/~pavlo/blog/index.html';
const { data: res } = await got(url);
const $ = load(res);

const list = $('.row.mb-3')
.toArray()
.map((element) => {
const $item = $(element);
const $title = $item.find('h4 a');
const $date = $item.find('.text-muted');
const $description = $item.find('p');

return {
title: $title.text().trim(),
link: $title.attr('href'),
description: $description.text().trim(),
pubDate: parseDate($date.attr('title')),
guid: $title.attr('href'),
};
});
return list;
}

export const route: Route = {
path: '/andypavlo/blog',
categories: ['blog'],
example: '/cmu/andypavlo/blog',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: 'Andy Pavlo Blog',
maintainers: ['mocusez'],
handler,
};

async function handler() {
const articles = await getArticles();
return {
title: 'Andy Pavlo - Carnegie Mellon University',
link: 'https://www.cs.cmu.edu/~pavlo/blog/index.html',
item: articles,
};
}
7 changes: 7 additions & 0 deletions lib/routes/cmu/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: 'Carnegie Mellon University',
url: 'www.cmu.edu',
lang: 'en',
};

0 comments on commit 94ce003

Please sign in to comment.