Skip to content

Commit 1814fe1

Browse files
committed
feat: read sponsors from disk and render them
1 parent 7953be5 commit 1814fe1

File tree

6 files changed

+105
-0
lines changed

6 files changed

+105
-0
lines changed

src/components/home/SectionSponsors.astro

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,40 @@
22
import { texts } from '../../i18n/home'
33
import SectionTitle from '../SectionTitle.astro'
44
import TextBox from '../TextBox.astro'
5+
import type { ISponsor } from '../../types/sponsors'
6+
import SponsorsGroup from './sponsors/SponsorsGroup.astro'
7+
8+
const sponsors = Object.values(import.meta.glob('../../data/sponsors/*.md', { eager: true })) as {
9+
frontmatter: ISponsor
10+
}[]
511
612
interface Props {
713
lang: string
814
}
915
1016
const { lang } = Astro.props
1117
const t = texts[lang as keyof typeof texts]
18+
19+
function filterSponsorsByTier(tier: string): ISponsor[] {
20+
return sponsors.filter((s) => s.frontmatter.tier === tier).map((s) => s.frontmatter)
21+
}
22+
23+
const bronze = filterSponsorsByTier('bronze')
24+
const silver = filterSponsorsByTier('silver')
25+
const gold = filterSponsorsByTier('gold')
26+
const platinum = filterSponsorsByTier('platinum')
27+
const main = filterSponsorsByTier('main')
1228
---
1329

1430
<div class="flex flex-col items-center gap-4">
1531
<SectionTitle title={t['sponsors.title']} />
1632
<TextBox text={t['sponsors.description']} />
33+
34+
<div class="flex flex-col w-full gap-8">
35+
<SponsorsGroup lang={lang} title={t['sponsors.main']} sponsors={main} />
36+
<SponsorsGroup lang={lang} title={t['sponsors.platinum']} sponsors={platinum} />
37+
<SponsorsGroup lang={lang} title={t['sponsors.gold']} sponsors={gold} />
38+
<SponsorsGroup lang={lang} title={t['sponsors.silver']} sponsors={silver} />
39+
<SponsorsGroup lang={lang} title={t['sponsors.bronze']} sponsors={bronze} />
40+
</div>
1741
</div>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
import type { ISponsor, TSponsorTier } from '../../../types/sponsors'
3+
import { texts } from '../../../i18n/home'
4+
5+
interface Props {
6+
lang: string
7+
title: string
8+
sponsors: ISponsor[]
9+
}
10+
11+
const { title, sponsors, lang } = Astro.props
12+
const t = texts[lang as keyof typeof texts]
13+
14+
const IMG_WITH_BY_TIER: Record<TSponsorTier, number> = {
15+
main: 200,
16+
platinum: 150,
17+
gold: 120,
18+
silver: 100,
19+
bronze: 80,
20+
}
21+
---
22+
23+
<div>
24+
<h4>{title}</h4>
25+
{
26+
sponsors.length > 0 ? (
27+
<div class="flex flex-wrap gap-4 mt-4">
28+
{sponsors.map((sponsor) => (
29+
<a
30+
href={sponsor.website}
31+
target="_blank"
32+
rel="noopener noreferrer"
33+
class="flex items-center justify-center p-4 border rounded-lg hover:shadow-lg transition-shadow duration-300"
34+
>
35+
<img src={sponsor.logo} alt={sponsor.name} width={IMG_WITH_BY_TIER[sponsor.tier]} />
36+
</a>
37+
))}
38+
</div>
39+
) : (
40+
<p class="text-gray-500 mt-2">{t['sponsors.none']}</p>
41+
)
42+
}
43+
</div>

src/data/sponsors/sponsor1.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
name: 'Sponsor 1'
3+
website: 'https://sponsor1.com'
4+
tier: 'bronze'
5+
logo: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBmaWxsPSIjZmZmIiBkPSJNNSAyMXEtLjgyNSAwLTEuNDEyLS41ODdUMyAxOVY1cTAtLjgyNS41ODgtMS40MTJUNSAzaDE0cS44MjUgMCAxLjQxMy41ODhUMjEgNXYxNHEwIC44MjUtLjU4NyAxLjQxM1QxOSAyMXptMC0yaDE0VjVINXptMCAwVjV6bTItMmgxMHEuMyAwIC40NS0uMjc1dC0uMDUtLjUyNWwtMi43NS0zLjY3NXEtLjE1LS4yLS40LS4ydC0uNC4yTDExLjI1IDE2TDkuNCAxMy41MjVxLS4xNS0uMi0uNC0uMnQtLjQuMmwtMiAyLjY3NXEtLjIuMjUtLjA1LjUyNVQ3IDE3bTIuNTYzLTcuNDM4UTEwIDkuMTI1IDEwIDguNXQtLjQzNy0xLjA2MlQ4LjUgN3QtMS4wNjIuNDM4VDcgOC41dC40MzggMS4wNjNUOC41IDEwdDEuMDYzLS40MzciLz48L3N2Zz4='
6+
---

src/data/sponsors/sponsor2.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
name: 'Sponsor 1'
3+
website: 'https://sponsor1.com'
4+
tier: 'platinum'
5+
logo: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBmaWxsPSIjZmZmIiBkPSJNNSAyMXEtLjgyNSAwLTEuNDEyLS41ODdUMyAxOVY1cTAtLjgyNS41ODgtMS40MTJUNSAzaDE0cS44MjUgMCAxLjQxMy41ODhUMjEgNXYxNHEwIC44MjUtLjU4NyAxLjQxM1QxOSAyMXptMC0yaDE0VjVINXptMCAwVjV6bTItMmgxMHEuMyAwIC40NS0uMjc1dC0uMDUtLjUyNWwtMi43NS0zLjY3NXEtLjE1LS4yLS40LS4ydC0uNC4yTDExLjI1IDE2TDkuNCAxMy41MjVxLS4xNS0uMi0uNC0uMnQtLjQuMmwtMiAyLjY3NXEtLjIuMjUtLjA1LjUyNVQ3IDE3bTIuNTYzLTcuNDM4UTEwIDkuMTI1IDEwIDguNXQtLjQzNy0xLjA2MlQ4LjUgN3QtMS4wNjIuNDM4VDcgOC41dC40MzggMS4wNjNUOC41IDEwdDEuMDYzLS40MzciLz48L3N2Zz4='
6+
---

src/i18n/home.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ export const texts = {
77
'sponsors.title': 'Patrocinios',
88
'sponsors.description':
99
'Gracias a las empresas que colaboran con la PyConES podemos ofrecer el mejor evento y experiencia posible. Somos una conferencia con un bajo coste de entrada capaz de ofrecer una experiencia de 3 días incluyendo regalos, almuerzos, comidas y meriendas. Además contamos con servicio de guardería, becas y traducción en directo a lenguaje de signos para que nadie se quede fuera. Con la ayuda de estas empresas conseguimos hacer un evento diverso e inclusivo enfocado en cuidar la comunidad de Python.',
10+
'sponsors.main': 'Patrocinador Principal',
11+
'sponsors.platinum': 'Patrocinador Platino',
12+
'sponsors.gold': 'Patrocinador Oro',
13+
'sponsors.silver': 'Patrocinador Plata',
14+
'sponsors.bronze': 'Patrocinador Bronce',
15+
'sponsors.none': 'No hay patrocinadores en este nivel',
1016
},
1117
en: {
1218
'index.initializing': 'Initialising system...',
@@ -16,6 +22,12 @@ export const texts = {
1622
'sponsors.title': 'Sponsorships',
1723
'sponsors.description':
1824
'Thanks to the companies that collaborate with PyConES, we can offer the best possible event and experience. We are a conference with a low entry cost capable of offering a 3-day experience including gifts, lunches, meals, and snacks. Additionally, we have childcare services, scholarships, and live sign language translation to ensure that no one is left out. With the help of these companies, we manage to create a diverse and inclusive event focused on caring for the Python community.',
25+
'sponsors.main': 'Main Sponsor',
26+
'sponsors.platinum': 'Platinum Sponsor',
27+
'sponsors.gold': 'Gold Sponsor',
28+
'sponsors.silver': 'Silver Sponsor',
29+
'sponsors.bronze': 'Bronze Sponsor',
30+
'sponsors.none': 'No sponsors in this tier',
1931
},
2032
ca: {
2133
'index.initializing': 'Inicialitzant sistema...',
@@ -25,5 +37,11 @@ export const texts = {
2537
'sponsors.title': 'Patrocinis',
2638
'sponsors.description':
2739
'Gràcies a les empreses que col·laboren amb la PyConES podem oferir el millor esdeveniment i experiència possible. Som una conferència amb un baix cost d’entrada capaç d’oferir una experiència de 3 dies incloent regals, àpats, menjars i berenars. A més comptem amb servei de guarderia, beques i traducció en directe a llenguatge de signes perquè ningú es quedi fora. Amb l’ajuda d’aquestes empreses aconseguim fer un esdeveniment divers i inclusiu enfocat en cuidar la comunitat de Python.',
40+
'sponsors.main': 'Patrocinador Principal',
41+
'sponsors.platinum': 'Patrocinador Platí',
42+
'sponsors.gold': 'Patrocinador Or',
43+
'sponsors.silver': 'Patrocinador Plata',
44+
'sponsors.bronze': 'Patrocinador Bronze',
45+
'sponsors.none': 'No hi ha patrocinadors en aquest nivell',
2846
},
2947
} as const

src/types/sponsors.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export type TSponsorTier = 'bronze' | 'silver' | 'gold' | 'platinum' | 'main'
2+
3+
export interface ISponsor {
4+
name: string
5+
website: string
6+
tier: TSponsorTier
7+
logo: string
8+
}

0 commit comments

Comments
 (0)