Skip to content

Commit

Permalink
Merge pull request #89 from gdgpescara/feat/add-slides-link
Browse files Browse the repository at this point in the history
Aggiunge la possibilità di inserire una slide composta da url e titolo
  • Loading branch information
gregoriopalama authored Dec 4, 2023
2 parents ae514e6 + 6458204 commit 7574e26
Show file tree
Hide file tree
Showing 4 changed files with 57 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
37 changes: 37 additions & 0 deletions src/pages/speaker-slides.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
import { getCollection } from "astro:content";
import { changeLanguage, t } from "i18next";
import Heading from "../components/Heading.astro";
import Section from "../components/Section.astro";
import Layout from "../layouts/Layout.astro";
changeLanguage("en");
const speakers = await getCollection("speakers");
---

<Layout title="Devfest Pescara 2023 - Location">
<Section additionalClass="dots pt-32 pb-16 md:py-32 xl:py-64">
<div class="max-w-screen-lg m-auto text-center">
<Heading level="h2" text="Slides" />
</div>
</Section>
<div class="max-w-screen-xl m-auto px-6 prose py-16 lg:py-32">
{
speakers.map((speaker) =>
speaker.data.slides ? (
<div>
<h2>{speaker.data.name}</h2>
<ul>
{speaker.data.slides.map((slide: any) => (
<li>
<a href={slide.url}>{slide.title}</a>
</li>
))}
</ul>
</div>
) : null,
)
}
</div>
</Layout>

0 comments on commit 7574e26

Please sign in to comment.