diff --git a/src/components/talk/Events.astro b/src/components/talk/Events.astro index 3c49b79f..16a5510f 100644 --- a/src/components/talk/Events.astro +++ b/src/components/talk/Events.astro @@ -1,12 +1,12 @@ --- import Markdown from "../Markdown.astro"; -interface Event { +export type Event = { date: string; location: string; name: string; online?: boolean; - time: string; + time?: string; url?: string; } diff --git a/src/pages/talks/[slug].astro b/src/pages/talks/[slug].astro index b8c41dd5..c3051497 100644 --- a/src/pages/talks/[slug].astro +++ b/src/pages/talks/[slug].astro @@ -5,8 +5,10 @@ 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"; -import { getSlugFromFile } from "~/utils.ts"; +import _ from "lodash"; +import type { Event } from "~/components/talk/Events"; import { getCollection } from "astro:content"; +import { getSlugFromFile } from "~/utils.ts"; export async function getStaticPaths() { const talks = await getCollection("talk"); @@ -21,6 +23,13 @@ export async function getStaticPaths() { const { Content } = await Astro.props.talk.render(); const { events, speakerdeck, title, video } = Astro.props.talk.data; + +const getOrderedEvents = (events: Record) => { + return _(events) + .sortBy((event: Event) => new Date(event.date)) + .reverse() + .value(); +}; --- @@ -33,7 +42,7 @@ const { events, speakerdeck, title, video } = Astro.props.talk.data; {video &&