import { unstable_cache } from "next/cache"; import { prisma } from "@/lib/db"; import { MangaGrid } from "@/components/MangaGrid"; import type { Metadata } from "next"; export const metadata: Metadata = { title: "Search", }; type Props = { searchParams: Promise<{ q?: string }>; }; const searchManga = unstable_cache( async (q: string) => prisma.manga.findMany({ where: { status: "PUBLISHED", title: { contains: q, mode: "insensitive" }, }, orderBy: { title: "asc" }, include: { _count: { select: { chapters: true } } }, }), ["search-manga"], { revalidate: 60 } ); export default async function SearchPage({ searchParams }: Props) { const { q } = await searchParams; const manga = q ? await searchManga(q) : []; return (

{q ? `Results for "${q}"` : "Search"}

{q ? ( ) : (

Use the search bar above to find manga

)}
); }