import type { Metadata } from "next"; import { notFound } from "next/navigation"; import { loadPublished } from "@/site/load"; import { fmtDate, fmtTime, Img } from "@/site/parts"; import { siteBase } from "@/site/meta"; import { Shell } from "@/site/Shell"; type Props = { params: Promise<{ slug: string }> }; async function find(slug: string) { const site = await loadPublished(); const event = site?.events.find((e) => e.from === "website" && e.url === `/events/${slug}`) ?? null; return { site, event }; } export async function generateMetadata({ params }: Props): Promise { const { site, event } = await find((await params).slug); if (!site || !event) return { robots: { index: false } }; return { metadataBase: siteBase(site), title: event.title, description: event.summary ?? undefined, alternates: { canonical: event.url } }; } /** A simple event made in the Website (ยง8). Cross Events' own events link to Cross Events instead. */ export default async function EventPage({ params }: Props) { const { site, event } = await find((await params).slug); if (!site || !event) notFound(); const zone = site.church?.timezone ?? "Africa/Johannesburg"; const events = site.snapshot.pages.find((p) => p.kind === "events"); return (

{fmtDate(event.startsAt, zone, { weekday: "long", day: "numeric", month: "long", year: "numeric" })}{!event.allDay && `, ${fmtTime(event.startsAt, zone)}`}

{event.title}

{event.location &&

{event.location}

} {event.summary &&

{event.summary}

} {events && All events}
); }