import { notFound } from "next/navigation"; import CodeViewer from "@/components/code-viewer"; import client from "@/lib/prisma"; import type { Metadata } from "next"; import { cache } from "react"; export async function generateMetadata({ params, }: { params: { id: string }; }): Promise { const generatedApp = await getGeneratedAppByID(params.id); let prompt = generatedApp?.prompt; if (typeof prompt !== "string") { notFound(); } let searchParams = new URLSearchParams(); searchParams.set("prompt", prompt); return { title: "An app generated on LlamaCoder.io", description: `Prompt: ${generatedApp?.prompt}`, openGraph: { images: [`/api/og?${searchParams}`], }, }; } export default async function Page({ params }: { params: { id: string } }) { // if process.env.DATABASE_URL is not set, throw an error if (typeof params.id !== "string") { notFound(); } const generatedApp = await getGeneratedAppByID(params.id); if (!generatedApp) { return
App not found
; } return ; } const getGeneratedAppByID = cache(async (id: string) => { return client.generatedApp.findUnique({ where: { id, }, }); });