File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 1+ import type { Namespace } from '@/types' ;
2+
3+ export const namespace : Namespace = {
4+ name : 'Ben Visness' ,
5+ url : 'bvisness.me' ,
6+ } ;
You can’t perform that action at this time.
0 commit comments