File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,7 +34,24 @@ async function generateIndex(orgIndices: ParsedOrgFile[]): Promise<AppIndex> {
3434 appIndex . apps . push ( ...apps ) ;
3535 }
3636
37- appIndex . apps = appIndex . apps . sort ( ( a , b ) => a . name < b . name ? - 1 : 1 ) ;
37+ appIndex . apps = appIndex . apps . sort ( ( a , b ) => {
38+ // Find the most recent release date for each app
39+ const getLatestDate = ( app : Application ) => {
40+ if ( ! Array . isArray ( app . releases ) || app . releases . length === 0 ) return new Date ( 0 ) . toISOString ( ) ;
41+ // Find the max date from the releases
42+ const initialDate = app . releases [ 0 ] ?. date || new Date ( 0 ) . toISOString ( ) ;
43+ return app . releases . reduce ( ( latest : string , curr : Application [ 'releases' ] [ number ] ) => {
44+ if ( ! curr . date ) return latest ;
45+ return ( new Date ( curr . date ) > new Date ( latest ) ? curr . date : latest ) ;
46+ } , initialDate ) ;
47+ } ;
48+
49+ const dateA = getLatestDate ( a ) ;
50+ const dateB = getLatestDate ( b ) ;
51+
52+ // Sort descending (most recent first)
53+ return new Date ( dateB ) . getTime ( ) - new Date ( dateA ) . getTime ( ) ;
54+ } ) ;
3855
3956 return appIndex ;
4057}
You can’t perform that action at this time.
0 commit comments