From b193d9ec9b37771f1e8a6e7a4efaae8d273a894b Mon Sep 17 00:00:00 2001 From: Daniele Irsuti Date: Sat, 2 Dec 2023 17:48:21 +0100 Subject: [PATCH] Refactor slidesUrl to slides array in Speaker and eventCollection --- src/components/SpeakersDetail.astro | 16 ++++++++-------- src/content/_content.ts | 7 ++++++- src/data/speaker.ts | 9 ++++++--- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/components/SpeakersDetail.astro b/src/components/SpeakersDetail.astro index 117d8b68..ea1dc592 100644 --- a/src/components/SpeakersDetail.astro +++ b/src/components/SpeakersDetail.astro @@ -37,17 +37,17 @@ if (!speaker) {
- {speaker.slidesUrl ? ( + {speaker.slides ? ( <>

{t("slides")}

- - {t("slides-link")} - + ) : null}
diff --git a/src/content/_content.ts b/src/content/_content.ts index 38153bd3..2e5caf83 100644 --- a/src/content/_content.ts +++ b/src/content/_content.ts @@ -44,7 +44,12 @@ const eventCollection = defineCollection({ duration: z.array(z.number()), // in minutes language: z.string(), speakers: z.array(reference("speakers")), - slidesUrl: z.string(), + slides: z.array( + z.object({ + url: z.string(), + title: z.string(), + }), + ), }), }); diff --git a/src/data/speaker.ts b/src/data/speaker.ts index ff401d95..a87a5a18 100644 --- a/src/data/speaker.ts +++ b/src/data/speaker.ts @@ -19,7 +19,10 @@ type Speaker = { blog: string; }; imageUrl: string; - slidesUrl: string; + slides: { + title: string; + url: string; + }[]; } & T; type SpeakerCollectionEntry = CollectionEntry<"speakers">; @@ -45,7 +48,7 @@ async function createSpeaker(person: SpeakerCollectionEntry) { blog: person?.data["social.blog"], }, imageUrl: person?.data.imageUrl, - slidesUrl: person?.data.slidesUrl, + slides: person.data.slides, }; return speaker; @@ -88,7 +91,7 @@ export async function getSpeakersWithoutBody() { blog: speaker.data["social.blog"], }, imageUrl: speaker.data.imageUrl, - slidesUrl: speaker?.data.slidesUrl, + slides: speaker?.data.slides, }) satisfies Omit, ), );