File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ export async function blogroll(): Promise<FeedEntry[]> {
12
12
. split ( "\n" ) . filter ( ( line ) => line . trim ( ) . length > 0 ) ;
13
13
const all_entries = ( await Promise . all ( urls . map ( blogroll_feed ) ) ) . flat ( ) ;
14
14
all_entries . sort ( ( a , b ) => b . date . getTime ( ) - a . date . getTime ( ) ) ;
15
- return all_entries ;
15
+ return newest_first ( all_entries ) ;
16
16
}
17
17
18
18
async function blogroll_feed (
@@ -28,13 +28,18 @@ async function blogroll_feed(
28
28
return [ ] ;
29
29
}
30
30
31
- return feed . entries . map ( ( entry : any ) => {
31
+ const entries_all : FeedEntry [ ] = feed . entries . map ( ( entry : any ) => {
32
32
return {
33
33
title : entry . title ! . value ! ,
34
34
url : ( entry . links . find ( ( it : any ) => {
35
35
it . type == "text/html" || it . href ! . endsWith ( ".html" ) ;
36
36
} ) ?? entry . links [ 0 ] ) ! . href ! ,
37
37
date : ( entry . published ?? entry . updated ) ! ,
38
38
} ;
39
- } ) . slice ( 0 , 3 ) ;
39
+ } ) ;
40
+ return newest_first ( entries_all ) . slice ( 0 , 3 ) ;
41
+ }
42
+
43
+ function newest_first ( entries : FeedEntry [ ] ) : FeedEntry [ ] {
44
+ return entries . toSorted ( ( a , b ) => b . date . getTime ( ) - a . date . getTime ( ) ) ;
40
45
}
You can’t perform that action at this time.
0 commit comments