import type { Metadata } from 'next';
import { social } from '@/lib/metadata';
import { EventsContent, type EventsData } from './events-content';
import { getDoc } from '@/lib/sanity';

export const metadata: Metadata = {
  title: 'Events & Summits',
  description: 'Where ideas meet opportunity. Decades of UEF trade summits, roundtables, and international gatherings.',
  ...social("Events & Summits", "Where ideas meet opportunity. Decades of UEF trade summits, roundtables, and international gatherings.", "/events"),
};

export const revalidate = 60;

const QUERY = `*[_id == "eventsPage"][0]{
  heroEyebrow, heroTitle, heroSubtitle,
  events[]{
    title, date, location, type, desc, highlights, status, link,
    "images": images[]{ "u": coalesce(image.asset->url, legacyPath) }.u,
    video, videoPoster
  }
}`;

export default async function Events() {
  const data = await getDoc<EventsData>(QUERY);
  return <EventsContent data={data} />;
}
