---
import BarcampPage from "../../components/BarcampPage.astro";
import EventPage from "../../components/EventPage.astro";
import { getEventByParams, getEventPageEntry, internalEvents } from "../../data/events";

export function getStaticPaths() {
  return internalEvents.map((event) => ({
    params: { year: event.year, slug: event.slug },
  }));
}

const { year, slug } = Astro.params;
const event = getEventByParams(year!, slug!);

if (!event) {
  return Astro.redirect("/");
}

const pageEntry = getEventPageEntry(event);
---

{event.slug === "barcamp" ? <BarcampPage event={event} pageEntry={pageEntry} /> : <EventPage event={event} pageEntry={pageEntry} />}
