Skip to content

Commit ee05c2e

Browse files
feat: add calendar integration and add more gigs
1 parent 8cf1787 commit ee05c2e

17 files changed

Lines changed: 248 additions & 34 deletions
255 KB
Loading
512 KB
Loading
228 KB
Loading
209 KB
Loading
200 KB
Loading
303 KB
Loading
183 KB
Loading

src/components/old/GigList.astro

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ type Gig = {
2323
city: string;
2424
daysGroup?: string;
2525
ticketsUrl?: string;
26+
title?: string;
27+
where?: string;
2628
};
2729
2830
type ParsedGig = Gig & {
@@ -65,10 +67,24 @@ const getImageAlt = (gig: ParsedGig) =>
6567
locale: ptBR,
6668
})}`;
6769
70+
function parseInBrazil(dateStr: string): Date {
71+
const [day, month, yearAndTime] = dateStr.split('/');
72+
const [year, time] = yearAndTime.split(' ');
73+
const [hours, minutes] = time.split(':');
74+
75+
return new Date(
76+
Number(year),
77+
Number(month) - 1,
78+
Number(day),
79+
Number(hours),
80+
Number(minutes)
81+
);
82+
}
83+
6884
const gigsByMonth = R.pipe(
6985
R.defaultTo([]),
7086
R.map((gig: Gig) => {
71-
const date = parse(gig.date, "dd/MM/yyyy HH:mm", Date.now());
87+
const date = parseInBrazil(gig.date);
7288
return {
7389
...gig,
7490
date,
@@ -103,29 +119,49 @@ const gigsByMonth = R.pipe(
103119
<p class="gig-day">
104120
<b>{daysGroup}</b>
105121
</p>
106-
{gigs.map((gig: ParsedGig) => (
107-
<>
108-
<p class="gig-city">
109-
<b>{gig.city}/{state.data.abbr} ↓↓↓</b>
110-
</p>
111-
<div class="gig-container">
112-
<Image
113-
src={`/images/posters/${gig.poster}`}
114-
alt={getImageAlt(gig)}
115-
width={600}
116-
height={800}
117-
format="webp"
118-
class="gig-poster"
119-
/>
120-
{gig.ticketsUrl && (
121-
<a href={gig.ticketsUrl} class="tickets-btn" target="_blank">
122-
<img src="/images/icons/ticket.svg" class="tickets-btn__icon" alt="Ícone de ingresso" />
123-
<span class="tickets-btn__text">Comprar ingressos</span>
122+
{gigs.map((gig: ParsedGig) => {
123+
const fullTitle = gig.title ?? "Show";
124+
const lines = [];
125+
if (gig.ticketsUrl) {
126+
lines.push(`Ingressos: ${gig.ticketsUrl}`);
127+
}
128+
lines.push('Divulgação: Undershows');
129+
const details = encodeURIComponent(lines.join('\n'));
130+
const location = gig.where ?? `${gig.city}/${state.data.abbr}`;
131+
const startDate = new Date(gig.date.getTime() + 3 * 60 * 60 * 1000);
132+
const endDate = new Date(startDate.getTime() + 1 * 60 * 1000);
133+
const start = format(startDate, "yyyyMMdd'T'HHmmss'Z'");
134+
const end = format(endDate, "yyyyMMdd'T'HHmmss'Z'");
135+
136+
const calendarUrl = `https://www.google.com/calendar/render?action=TEMPLATE&text=${encodeURIComponent(fullTitle)}&dates=${start}/${end}&details=${details}&location=${encodeURIComponent(location)}`;
137+
138+
return (
139+
<>
140+
<p class="gig-city">
141+
<b>{gig.city}/{state.data.abbr} ↓↓↓</b>
142+
</p>
143+
<div class="gig-container">
144+
<Image
145+
src={`/images/posters/${gig.poster}`}
146+
alt={getImageAlt(gig)}
147+
width={600}
148+
height={800}
149+
format="webp"
150+
class="gig-poster"
151+
/>
152+
{gig.ticketsUrl && (
153+
<a href={gig.ticketsUrl} class="tickets-btn" target="_blank">
154+
<img src="/images/icons/ticket.svg" class="tickets-btn__icon" alt="Ícone de ingresso" />
155+
<span class="tickets-btn__text">Comprar ingressos</span>
156+
</a>
157+
)}
158+
<a href={calendarUrl} target="_blank" class="calendar-btn" rel="noopener noreferrer">
159+
📅 Adicionar no calendário
124160
</a>
125-
)}
126-
</div>
127-
</>
128-
))}
161+
</div>
162+
</>
163+
);
164+
})}
129165
</>
130166
))}
131167
</>

src/content/config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ const stateCollection = defineCollection({
1515
/^(0[1-9]|[1-2][0-9]|3[0-1])(\/(0[1-9]|[1-2][0-9]|3[0-1]))*$/,
1616
{ message: 'Invalid days group. Example: 09/10/11' }
1717
).optional(),
18-
ticketsUrl: z.string().url().optional()
18+
ticketsUrl: z.string().url().optional(),
19+
title: z.string().optional(),
20+
where: z.string().optional()
1921
})).optional()
2022
})
2123
});
2224

2325
export const collections = {
24-
'state': stateCollection
26+
state: stateCollection
2527
};

src/content/state/ce.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ gigs:
88
daysGroup: 03/04/05
99
ticketsUrl: >-
1010
https://www.sympla.com.br/evento/colera-em-fortaleza-ce-nordeste-tour-2025-ophera-music-bar/2839985
11+
title: Cólera + Diagnose + Pex + Abismo + Lixorganico
12+
where: Ophera Music Bar
1113
---
1214

0 commit comments

Comments
 (0)