File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ import type { Namespace } from '@/types' ;
2
+
3
+ export const namespace : Namespace = {
4
+ name : '道宣的窝' ,
5
+ url : 'daoxuan.cc' ,
6
+ lang : 'zh-CN' ,
7
+ } ;
Original file line number Diff line number Diff line change
1
+ import { Route } from '@/types' ;
2
+ import got from '@/utils/got' ;
3
+ import { load } from 'cheerio' ;
4
+ import { parseDate } from '@/utils/parse-date' ;
5
+
6
+ export const route : Route = {
7
+ path : '/' ,
8
+ categories : [ 'blog' ] ,
9
+ example : '/daoxuan' ,
10
+ radar : [
11
+ {
12
+ source : [ 'daoxuan.cc/' ] ,
13
+ } ,
14
+ ] ,
15
+ name : '推荐阅读文章' ,
16
+ maintainers : [ 'dx2331lxz' ] ,
17
+ url : 'daoxuan.cc/' ,
18
+ handler,
19
+ } ;
20
+
21
+ async function handler ( ) {
22
+ const url = 'https://daoxuan.cc/' ;
23
+ const response = await got ( { method : 'get' , url } ) ;
24
+ const $ = load ( response . data ) ;
25
+ const items = $ ( 'div.recent-post-item' )
26
+ . toArray ( )
27
+ . map ( ( item ) => {
28
+ item = $ ( item ) ;
29
+ const a = item . find ( 'a.article-title' ) . first ( ) ;
30
+ const timeElement = item . find ( 'time' ) . first ( ) ;
31
+ return {
32
+ title : a . attr ( 'title' ) ,
33
+ link : `https://daoxuan.cc${ a . attr ( 'href' ) } ` ,
34
+ pubDate : parseDate ( timeElement . attr ( 'datetime' ) ) ,
35
+ description : a . attr ( 'title' ) ,
36
+ } ;
37
+ } ) ;
38
+ return {
39
+ title : '道宣的窝' ,
40
+ link : url ,
41
+ item : items ,
42
+ } ;
43
+ }
You can’t perform that action at this time.
0 commit comments