import { prisma } from "@/lib/db";
import { collectGenres } from "@/lib/genres";
import { TrendingCarousel } from "@/components/TrendingCarousel";
import { GenreTabs } from "@/components/GenreTabs";

export const revalidate = 300;

export default async function Home() {
  const manga = await prisma.manga.findMany({
    where: { status: "PUBLISHED" },
    orderBy: { updatedAt: "desc" },
    include: { _count: { select: { chapters: true } } },
  });

  const trending = manga.slice(0, 10);
  const genres = collectGenres(manga);

  return (
    <div className="max-w-6xl mx-auto px-4 py-5 space-y-8">
      <TrendingCarousel manga={trending} />
      <GenreTabs manga={manga} genres={genres} />
    </div>
  );
}
