Skip to content

Commit 0272da3

Browse files
committed
Clean up layouts and types.
1 parent 932a10b commit 0272da3

File tree

6 files changed

+26
-111
lines changed

6 files changed

+26
-111
lines changed

src/components/schedule/day.astro

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
---
3-
import { getEntry, getCollection } from "astro:content";
3+
import { type CollectionEntry, getEntry, getCollection } from "astro:content";
44
import Break from "@components/schedule/break.astro";
55
import Session from "@components/schedule/session.astro";
66
import { addMinutes, differenceInMinutes, parseISO } from "date-fns";
@@ -11,12 +11,10 @@ import { Select } from "@components/form/select";
1111
import { formatInTimeZone } from "date-fns-tz";
1212

1313

14-
export interface props {
15-
dayName: string;
16-
eventType?: string | null;
14+
interface Props {
15+
day: CollectionEntry<"days">;
1716
}
1817

19-
2018
const format = (date: Date, format: string) => {
2119
return formatInTimeZone(date, "Europe/Prague", format);
2220
};
@@ -41,14 +39,11 @@ export const getStaticPaths = async () => {
4139
};
4240

4341

44-
const { dayName } = Astro.props;
45-
46-
const days = await getCollection("days");
47-
48-
//const day = await getEntry("days", dayName);
49-
const day = await getEntry("days", dayName);
42+
const { day } = Astro.props;
43+
const dayName = day.id;
44+
//const day = getEntry("days", dayName);
5045

51-
const ROOMS = (day?.data.rooms ?? [])
46+
const ROOMS = (day.data.rooms ?? [])
5247
.filter((room) => room.toLowerCase() !== "exhibit hall")
5348
.sort();
5449

@@ -67,7 +62,7 @@ type ScheduleSession = {
6762
// hack for posters :)
6863
const posters: Array<ScheduleSession> = [];
6964

70-
const sessions = day?.data.events
65+
const sessions = day.data.events
7166
.map((event) => {
7267
const start = parseISO(event.start);
7368
const startTime = format(start, "HH:mm");

src/pages/schedule.astro

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import ScheduleDay from "@components/schedule/day.astro";
55
import Headline from "@ui/Headline.astro";
66
import Button from "@ui/Button.astro";
77
8+
interface Props {
9+
dayName: string;
10+
}
11+
812
export const getStaticPaths = async () => {
913
const days = await getCollection("days");
1014
@@ -15,18 +19,14 @@ export const getStaticPaths = async () => {
1519
1620
const days = await getCollection("days");
1721
18-
const allDays = Array.from(
19-
new Set(days.map((day) => day.id).filter((id) => id))
20-
).sort();
21-
2222
---
2323

2424
<Layout title="" description="">
2525

2626
<Headline as="h2" id=`schedule-main` title="2025 Schedule" />
2727
{
2828
days.map((day) => (
29-
<ScheduleDay dayName={day.id} />
29+
<ScheduleDay day={day} />
3030
))
3131
}
3232
</Layout>

src/pages/schedule/_[type].astro

Lines changed: 0 additions & 74 deletions
This file was deleted.

src/pages/schedule/day/[day].astro

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
import { getEntry, getCollection } from "astro:content";
2+
import { type CollectionEntry, getEntry, getCollection } from "astro:content";
33
import Layout from "@layouts/ScheduleLayout.astro";
44
import ScheduleDay from "@components/schedule/day.astro";
55
import Headline from "@ui/Headline.astro";
@@ -13,15 +13,18 @@ export const getStaticPaths = async () => {
1313
});
1414
};
1515
16-
const days = await getCollection("days");
1716
18-
const allDays = Array.from(
19-
new Set(days.map((day) => day.id).filter((id) => id))
20-
).sort();
21-
let isActive = true;
17+
type Day = CollectionEntry<"days">;
18+
const dayEntry = await getEntry("days", Astro.params.day);
19+
20+
if (!dayEntry) {
21+
throw new Error(`Day entry "${Astro.params.day}" not found`);
22+
}
23+
24+
const day: Day = dayEntry;
2225
---
2326

2427
<Layout title="" description="">
2528
<Headline as="h2" id=`schedule-main` title="2025 Schedule" />
26-
<ScheduleDay dayName={Astro.params.day} />
29+
<ScheduleDay day={day} />
2730
</Layout>

src/pages/schedule/talks.astro

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
import { getCollection } from "astro:content";
2+
import { type CollectionEntry, getCollection } from "astro:content";
33
import Layout from "@layouts/ScheduleLayout.astro";
44
import ScheduleDay from "@components/schedule/day.astro";
55
import { slugify } from '@utils/content';
@@ -22,11 +22,6 @@ export const getStaticPaths = async () => {
2222
2323
const days = await getCollection("days");
2424
25-
const allDays = Array.from(
26-
new Set(days.map((day) => day.id).filter((id) => id))
27-
).sort();
28-
29-
3025
---
3126

3227
<Layout title="" description="">
@@ -39,7 +34,7 @@ const allDays = Array.from(
3934
return dayOfWeek !== 1 && dayOfWeek !== 2;
4035
})
4136
.map((day) => (
42-
<ScheduleDay dayName={day.id} />
37+
<ScheduleDay day={day} />
4338
))
4439
}
4540
</Layout>

src/pages/schedule/tutorials.astro

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ export const getStaticPaths = async () => {
2222
2323
const days = await getCollection("days");
2424
25-
const allDays = Array.from(
26-
new Set(days.map((day) => day.id).filter((id) => id))
27-
).sort();
28-
2925
---
3026

3127
<Layout title="" description="">
@@ -38,7 +34,7 @@ const allDays = Array.from(
3834
return dayOfWeek == 1 || dayOfWeek == 2;
3935
})
4036
.map((day) => (
41-
<ScheduleDay dayName={day.id} />
37+
<ScheduleDay day={day} />
4238
))
4339
}
4440
</Layout>

0 commit comments

Comments
 (0)