From ad3c9171f730dd45707a2d4fdb2f174af00a74f3 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sat, 15 Oct 2022 14:28:36 +0100 Subject: [PATCH] refactor(talks): extract talk components --- website/src/components/talk/Events.astro | 42 +++++++++++++++ website/src/components/talk/Slides.astro | 22 ++++++++ website/src/components/talk/Video.astro | 25 +++++++++ website/src/pages/talks/[slug].astro | 68 ++++-------------------- 4 files changed, 98 insertions(+), 59 deletions(-) create mode 100644 website/src/components/talk/Events.astro create mode 100644 website/src/components/talk/Slides.astro create mode 100644 website/src/components/talk/Video.astro diff --git a/website/src/components/talk/Events.astro b/website/src/components/talk/Events.astro new file mode 100644 index 00000000..92c2837d --- /dev/null +++ b/website/src/components/talk/Events.astro @@ -0,0 +1,42 @@ +--- +interface Event { + date: string + location: string + name: string + online?: boolean + time: string + url?: string +} + +interface Props { + events: Event[] +} + +const { events } = Astro.props +--- + +{events && ( +
+

Events

+ +
+
    + {events.map((event) => ( +
  • + {event.url ? ({event.name}) : event.name} + + {event.location && `in ${event.location}`} + + - {new Date(event.date).toLocaleDateString('en-GB', { + day: 'numeric', + month: 'long', + year: 'numeric', + })} + + {event.online && '(online)'} +
  • + ))} +
+
+
+)} diff --git a/website/src/components/talk/Slides.astro b/website/src/components/talk/Slides.astro new file mode 100644 index 00000000..19710b7b --- /dev/null +++ b/website/src/components/talk/Slides.astro @@ -0,0 +1,22 @@ +--- +interface Props { + id: string + ratio?: string +} + +const { id, ratio }: Props = Astro.props +--- + +
+

Slides

+ +
+ + +
+
diff --git a/website/src/components/talk/Video.astro b/website/src/components/talk/Video.astro new file mode 100644 index 00000000..cc208156 --- /dev/null +++ b/website/src/components/talk/Video.astro @@ -0,0 +1,25 @@ +--- +interface Props { + id: string + type: string +} + +const { id, type }: Props = Astro.props +--- + +{type == "youtube" && ( +
+

Video

+ +
+ +
+
+)} diff --git a/website/src/pages/talks/[slug].astro b/website/src/pages/talks/[slug].astro index 07b05395..16fc746f 100644 --- a/website/src/pages/talks/[slug].astro +++ b/website/src/pages/talks/[slug].astro @@ -1,6 +1,9 @@ --- +import Events from '../../components/talk/Events.astro' import Layout from '../../layouts/Layout.astro' import Markdown from '../../components/Markdown.astro' +import Slides from '../../components/talk/Slides.astro' +import Video from '../../components/talk/Video.astro' export async function getStaticPaths() { const talks = await Astro.glob('../../talks/*.md') @@ -16,17 +19,8 @@ export async function getStaticPaths() { }) } -interface Event { - date: string - location: string - name: string - online?: boolean - time: string - url?: string -} - const { Content } = Astro.props.talk -const { events, title, speakerdeck, video }: { events: Event[] } = Astro.props.talk.frontmatter +const { events, speakerdeck, title, video } = Astro.props.talk.frontmatter --- @@ -35,58 +29,14 @@ const { events, title, speakerdeck, video }: { events: Event[] } = Astro.props.t - {speakerdeck && speakerdeck.id && ( -
-

Slides

- -
- - -
-
+ {speakerdeck && ( + )} - {video && video.type == "youtube" && ( -
-

Video

- -
- -
-
+ {video && ( +