File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,7 +10,15 @@ export async function load() {
1010 // Filter for markdown files (exclude _.md)
1111 const essayFiles = files
1212 . filter ( ( file : string ) => file . endsWith ( '.md' ) && file !== '_.md' )
13- . sort ( ( a : string , b : string ) => b . localeCompare ( a ) ) ; // Sort in reverse chronological order
13+ . sort ( ( a : string , b : string ) => {
14+ const dateValue = ( name : string ) => {
15+ const head = name . split ( '_' ) [ 0 ] ?? '' ;
16+ const [ y , m ] = head . split ( '-' ) . map ( Number ) ;
17+ // default to 0 if missing to keep non-conforming names at the end
18+ return new Date ( y || 0 , ( m ? m - 1 : 0 ) , 1 ) . getTime ( ) ;
19+ } ;
20+ return dateValue ( b ) - dateValue ( a ) ; // newest first
21+ } ) ;
1422
1523 // Extract metadata from filenames
1624 const essays = essayFiles . map ( ( file : string ) => {
Original file line number Diff line number Diff line change 44
55
66Next essay:
7- - Fancy Rug effect (IP )
7+ - What's the best amount of money? (A: enough )
88- Walking is a superpower
99- Civil discourse and complete thoughts
1010
You can’t perform that action at this time.
0 commit comments