* Fetches supporters data from Open Collective API and GitHub Sponsors, filters active backers, * and maps it to the Supporters type. * * @returns {Promise >} Array of supporte
()
| 219 | * @returns {Promise<Array<import('#site/types/supporters').OpenCollectiveSupporter | import('#site/types/supporters').GitHubSponsorSupporter>>} Array of supporters |
| 220 | */ |
| 221 | async function sponsorsData() { |
| 222 | const seconds = 300; // Change every 5 minutes |
| 223 | const seed = Math.floor(Date.now() / (seconds * 1000)); |
| 224 | |
| 225 | const sponsorsResults = await Promise.allSettled([ |
| 226 | fetchGithubSponsorsData(), |
| 227 | fetchOpenCollectiveData(), |
| 228 | ]); |
| 229 | |
| 230 | const sponsors = sponsorsResults.flatMap(result => { |
| 231 | if (result.status === 'fulfilled') { |
| 232 | return result.value; |
| 233 | } |
| 234 | |
| 235 | console.error('Supporters data source failed:', result.reason); |
| 236 | return []; |
| 237 | }); |
| 238 | |
| 239 | const shuffled = await shuffle(sponsors, seed); |
| 240 | |
| 241 | return shuffled; |
| 242 | } |
| 243 | |
| 244 | export default sponsorsData; |
nothing calls this directly
no test coverage detected