Skip to content

Commit 685598f

Browse files
authored
feat(route): add bvisness.me blog route (#20929)
1 parent 04330df commit 685598f

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

lib/routes/bvisness/blog.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { load } from 'cheerio';
2+
3+
import type { Route } from '@/types';
4+
import ofetch from '@/utils/ofetch';
5+
import { parseDate } from '@/utils/parse-date';
6+
7+
export const route: Route = {
8+
name: 'Blog',
9+
categories: ['blog'],
10+
maintainers: ['raxod502'],
11+
path: '/blog',
12+
example: '/bvisness/blog',
13+
handler,
14+
radar: [
15+
{
16+
source: ['bvisness.me'],
17+
target: '/blog',
18+
},
19+
],
20+
};
21+
22+
async function handler() {
23+
const response = await ofetch('https://bvisness.me/');
24+
const $ = load(response);
25+
26+
const items = $('article')
27+
.toArray()
28+
.map((item) => {
29+
item = $(item);
30+
const a = item.find('a').first();
31+
return {
32+
title: a.text(),
33+
link: new URL(a.attr('href'), 'https://bvisness.me/').href,
34+
pubDate: parseDate(item.find('time').attr('datetime')),
35+
};
36+
});
37+
38+
return {
39+
title: 'Ben Visness Blog',
40+
link: 'https://bvisness.me/',
41+
item: items,
42+
};
43+
}

lib/routes/bvisness/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: 'Ben Visness',
5+
url: 'bvisness.me',
6+
};

0 commit comments

Comments
 (0)