import { Suspense } from "react" import { Metadata } from "next" import prisma from "@/lib/prisma" import { ExploreClient } from "@/components/explore/explore-client" import { Loader2 } from "lucide-react" import { generateSEO } from "@/lib/seo" const BASE_URL = process.env.NEXT_PUBLIC_APP_URL || 'https://open-prompt.netlify.app' // Revalidate every 30 seconds instead of force-dynamic export const revalidate = 30 export const metadata: Metadata = generateSEO({ title: "Explore AI Prompts | OpenPrompt", description: "Discover and run AI prompts created by the community. Find prompts for content, coding, marketing, business, education, and more.", url: `${BASE_URL}/explore`, keywords: ["explore prompts", "discover AI prompts", "community prompts", "prompt search", "AI prompt library"], }) as Metadata async function getInitialPrompts(category?: string, search?: string, sort?: string) { try { const orderBy: Record[] = [] switch (sort) { case 'recent': orderBy.push({ createdAt: 'desc' }) break case 'stars': orderBy.push({ starsCount: 'desc' }) break case 'runs': orderBy.push({ totalRuns: 'desc' }) break default: orderBy.push({ totalRuns: 'desc' }) } orderBy.push({ id: 'desc' }) const where: Record = { visibility: 'public', } if (category) { where.category = category } if (search) { where.OR = [ { title: { contains: search, mode: 'insensitive' } }, { description: { contains: search, mode: 'insensitive' } }, ] } const prompts = await prisma.prompt.findMany({ where, include: { creator: { select: { name: true, username: true, image: true, }, }, }, orderBy, take: 12, }) return prompts } catch (error) { console.error('Explore page data fetch error:', error) return [] } } interface ExplorePageProps { searchParams: Promise<{ [key: string]: string | undefined }> } export default async function ExplorePage({ searchParams }: ExplorePageProps) { const params = await searchParams const initialPrompts = await getInitialPrompts( params.category, params.q, params.sort ) return (
{/* Page Header */}

Explore Prompts

Discover AI prompts created by the community

{/* Client Component with Search/Filter */}
}> ) }