Skip to content

Commit 6899f48

Browse files
committed
add sprint and open space tiers; allow sponsors to belong to multiple tiers
1 parent be75dd7 commit 6899f48

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

src/components/sections/sponsors/sponsors.astro

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ const tiers = [
1717
"Startups",
1818
"Bronze",
1919
"Patron",
20+
"Sprint",
2021
"Financial Aid",
21-
"Supporters",
22+
"Open Space",
23+
"Supporters",
2224
"Partners",
2325
"Media Partners"
2426
] as const;
@@ -27,10 +29,20 @@ const sponsors = await getCollection("sponsors");
2729
2830
let hasSponsors = false;
2931
32+
function getSponsorTiers(sponsor) {
33+
if (typeof sponsor.data.tier === 'string') {
34+
return sponsor.data.tier.split(',').map(tier => tier.trim());
35+
}
36+
return Array.isArray(sponsor.data.tier) ? sponsor.data.tier : [sponsor.data.tier];
37+
}
38+
3039
const sponsorTiers = tiers
3140
.map((tier) => {
3241
const tierSponsors = sponsors.filter(
33-
(sponsor) => sponsor.data.tier === tier,
42+
(sponsor) => {
43+
const sponsorTiers = getSponsorTiers(sponsor);
44+
return sponsorTiers.includes(tier);
45+
}
3446
);
3547
3648
if (tierSponsors.length > 0) {

src/pages/sponsors.astro

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,30 @@ const tiers = [
2323
"Silver",
2424
"Bronze",
2525
"Patron",
26+
"Sprint",
2627
"Financial Aid",
28+
"Open Space",
2729
"Supporters",
2830
"Partners",
2931
] as const;
3032
33+
function getSponsorTiers(sponsor) {
34+
if (typeof sponsor.data.tier === 'string') {
35+
return sponsor.data.tier.split(',').map(tier => tier.trim());
36+
}
37+
return Array.isArray(sponsor.data.tier) ? sponsor.data.tier : [sponsor.data.tier];
38+
}
39+
3140
// Group sponsors by their tier
3241
const grouped = sponsors.reduce((acc, sponsor) => {
33-
const tier = sponsor.data.tier;
42+
const sponsorTiers = getSponsorTiers(sponsor);
43+
sponsorTiers.forEach(tier => {
3444
const key = tier ?? 'unknown';
3545
if (!acc[key]) {
3646
acc[key] = [];
3747
}
3848
acc[key].push(sponsor);
49+
});
3950
return acc;
4051
}, {} as Record<string, CollectionEntry<"sponsors">[]>);
4152
---

0 commit comments

Comments
 (0)