import { graphql } from "@/gql";
import { getClient } from "@/app/client";
import { NewsList } from "@/components/news/NewsList";
import Link from "next/link";
import { PageHeader } from "@/components/general/PageHeader";
import { newsQuery, NewsFragment, NewsIndexFragment } from "@/lib/news";

export default async function Page() {
  const { data, error } = await getClient().query(newsQuery, {});
  const news = (data?.news ?? []) as NewsFragment[];
  const index = (data?.index ?? []) as NewsIndexFragment;

  return (
    <main className="site-main" id="main">
      <PageHeader heading={index.title} lead={index.lead} align="left" />
      <NewsList news={news} />
    </main>
  );
}
