Skip to content

Commit

Permalink
Refactor slidesUrl to slides array in Speaker and
Browse files Browse the repository at this point in the history
eventCollection
  • Loading branch information
irsooti committed Dec 2, 2023
1 parent ae514e6 commit b193d9e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
16 changes: 8 additions & 8 deletions src/components/SpeakersDetail.astro
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ if (!speaker) {
<div class="bg-[#232323] py-16 max-w-screen-lg mx-auto xl:mx-0 text-xl px-10 text-left xl:text-left text-base-content xl:py-16 rounded-xl prose">
<speaker.Bio.Content />

{speaker.slidesUrl ? (
{speaker.slides ? (
<>
<h3>{t("slides")}</h3>

<a
class="btn btn-secondary"
href={speaker.slidesUrl}
class="text-primary-500 hover:underline"
>
{t("slides-link")}
</a>
<ul>
{speaker.slides.map((slide) => (
<li>
<a href={slide.url}>{slide.title}</a>
</li>
))}
</ul>
</>
) : null}
</div>
Expand Down
7 changes: 6 additions & 1 deletion src/content/_content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}),
),
}),
});

Expand Down
9 changes: 6 additions & 3 deletions src/data/speaker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ type Speaker<T = {}> = {
blog: string;
};
imageUrl: string;
slidesUrl: string;
slides: {
title: string;
url: string;
}[];
} & T;

type SpeakerCollectionEntry = CollectionEntry<"speakers">;
Expand All @@ -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;
Expand Down Expand Up @@ -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<Speaker, "Bio">,
),
);
Expand Down

0 comments on commit b193d9e

Please sign in to comment.