File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
docs/.vuepress/components Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ interface Repo {
3636 homepage: string ;
3737 description: string ;
3838 topics: string [];
39+ stargazers_count: number ; // Add this field
40+ created_at: string ; // Add this field
3941}
4042
4143const props = defineProps <{
@@ -66,14 +68,30 @@ async function fetchProjects() {
6668
6769 const repos = await response .json ();
6870
71+ // Add sorting logic here
6972 projects .value = repos
70- .filter ((repo : any ) => repo .homepage && repo .name .toLowerCase () !== mainRepoName .value )
73+ .filter (
74+ (repo : any ) =>
75+ repo .homepage && repo .name .toLowerCase () !== mainRepoName .value ,
76+ )
7177 .map ((repo : any ) => ({
7278 name: repo .name ,
7379 homepage: repo .homepage ,
7480 description: repo .description ,
7581 topics: repo .topics || [],
76- }));
82+ stargazers_count: repo .stargazers_count , // Map the field
83+ created_at: repo .created_at , // Map the field
84+ }))
85+ .sort ((a : Repo , b : Repo ) => {
86+ // Sort by stars descending
87+ if (a .stargazers_count !== b .stargazers_count ) {
88+ return b .stargazers_count - a .stargazers_count ;
89+ }
90+ // If stars are equal, sort by creation date descending
91+ return (
92+ new Date (b .created_at ).getTime () - new Date (a .created_at ).getTime ()
93+ );
94+ });
7795 } catch (err : any ) {
7896 error .value = err .message || " Unknown error" ;
7997 } finally {
You can’t perform that action at this time.
0 commit comments