Skip to content

Commit 0351df8

Browse files
committed
Refactor code structure for improved readability and maintainability
1 parent 0b099e4 commit 0351df8

2 files changed

Lines changed: 318 additions & 326 deletions

File tree

sponsor.config.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,11 @@ interface JSONSponsor {
1010
amount: number;
1111
link: string;
1212
org: boolean;
13-
/**
14-
* The ISO string representing when the sponsorship was created. This can be used to determine how long someone has been sponsoring.
15-
*/
1613
createdAt?: string;
1714

1815
tierTitle: string;
19-
/**
20-
* The tier level of the sponsor, where 0 is the lowest tier (e.g. Past Sponsors) and higher numbers indicate higher tiers.
21-
*/
2216
tierLevel: number;
23-
24-
/**
25-
* Determines how the sponsor should be displayed in the website sidebar.
26-
* This is only used for sponsors that define a custom `sidebarLogo` in
27-
* `SPONSOR_CUSTOMIZATIONS` and meet the amount requirements.
28-
*/
2917
sidebarSize: SidebarPlacementSize;
30-
/**
31-
* The URL of the logo to use for the sponsor's sidebar placement.
32-
*
33-
* @default The sponsor's avatar URL from GitHub Sponsors.
34-
*/
3518
sidebarLogo: string;
3619
}
3720

@@ -205,7 +188,16 @@ export default defineConfig({
205188
customization?.sidebarLogo || sponsorEntry.sponsor.avatarUrl,
206189
} satisfies JSONSponsor;
207190
})
208-
.sort((a, b) => b.amount - a.amount);
191+
.sort((a, b) => {
192+
const amountDiff = b.amount - a.amount;
193+
if (amountDiff !== 0) {
194+
return amountDiff;
195+
}
196+
197+
const createdAtA = a.createdAt ? new Date(a.createdAt).getTime() : 0;
198+
const createdAtB = b.createdAt ? new Date(b.createdAt).getTime() : 0;
199+
return createdAtA - createdAtB;
200+
});
209201

210202
await fs.writeFile('sponsors.json', `${JSON.stringify(json, null, 2)}\n`);
211203
},

0 commit comments

Comments
 (0)