import type { Metadata } from "next"; import { notFound } from "next/navigation"; import Link from "next/link"; import { Mic2, Repeat } from "lucide-react"; import { requireAuth } from "@/lib/auth/guards"; import { prisma } from "@/lib/db"; import { PageHeader } from "@/components/app/page-header"; import { GenerationProgress } from "@/components/app/generation-progress"; import { ScriptEditor } from "@/components/app/script-editor"; import { AudioPlayer } from "@/components/app/audio-player"; import { EpisodeActions } from "@/components/app/episode-actions"; import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import type { StructuredScript } from "@/lib/ai/types"; export async function generateMetadata({ params, }: { params: Promise<{ id: string }>; }): Promise { const { id } = await params; // Title only — this is an authed page and the route group is already noindex. const episode = await prisma.episode.findUnique({ where: { id }, select: { title: true } }); return { title: episode?.title ?? "Episode" }; } export default async function EpisodePage({ params }: { params: Promise<{ id: string }> }) { const { id } = await params; const session = await requireAuth(); const episode = await prisma.episode.findUnique({ where: { id }, include: { script: true, audioAsset: true, coverArt: true, speakers: true }, }); if (!episode) notFound(); if (episode.userId !== session.user.id && session.user.role !== "admin") notFound(); const inProgress = !["READY", "FAILED"].includes(episode.status); const speakerNames: Record = {}; for (const s of episode.speakers) speakerNames[s.speakerKey] = s.displayName; return ( <> ) : undefined } /> {episode.moderatedAt ? (

This episode was removed

It was reviewed against our Acceptable Use Policy and taken down on{" "} {episode.moderatedAt.toLocaleDateString()}. Its public link and downloads are disabled. If you think this was a mistake, reply to your support thread and we will take another look.

) : null} {episode.status === "FAILED" || inProgress ? ( ) : (
{episode.coverArt ? ( // eslint-disable-next-line @next/next/no-img-element {episode.title} ) : (
)}
{episode.audioAsset && ( )}
{episode.script ? ( ) : ( No script available. )}
)} ); }