export const dynamic = "force-dynamic"; import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { getTranscription, getAdjacentTranscriptions, } from "@/lib/transcriptions"; import { buildOgMeta, ogForTranscription, extractQuoteFromHl } from "@/lib/og"; import { PageHeader } from "@/components/page-header"; import { Card, CardContent } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { buttonVariants } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import { ChevronLeft, ChevronRight, Clock, MapPin, Users } from "lucide-react"; import { PlayAudioButton } from "./play-audio-button"; export async function generateMetadata({ params, searchParams, }: { params: Promise<{ slug: string }>; searchParams: Promise>; }): Promise { const { slug } = await params; const sp = await searchParams; const t = await getTranscription(slug); if (!t) return {}; const detail = [t.date, t.place].filter(Boolean).join(" · "); // Build paragraphs from content blocks for hl matching const paragraphs = t.content.map((b) => { const speakerPrefix = b.speaker ? `${b.speaker}: ` : ""; return speakerPrefix + b.text.replace(/<[^>]+>/g, ""); }); const hlQuote = extractQuoteFromHl(sp, paragraphs); if (hlQuote) { return buildOgMeta({ title: `Transcripts: ${t.name}`, detail: detail || undefined, quote: hlQuote, }); } // Fallback: find a good Prabhupāda quote from the content const spQuote = t.content .find((b) => b.speaker === "Prabhupāda" && b.text.length > 50) ?.text?.replace(/<[^>]+>/g, "") .slice(0, 200); if (spQuote) { return buildOgMeta({ title: t.name, detail: detail || undefined, quote: spQuote, }); } return ogForTranscription(`Transcripts: ${t.name}`, detail || undefined); } export default async function TranscriptionPage({ params, }: { params: Promise<{ slug: string }>; }) { const { slug } = await params; const t = await getTranscription(slug); if (!t) notFound(); const { prev, next } = await getAdjacentTranscriptions(slug, t.year); const backHref = t.year ? `/transcriptions/year/${t.year}` : "/transcriptions"; const backLabel = t.year ? `Transcriptions from ${t.year}` : "Transcriptions"; return (
← {backLabel}

{t.name}

{t.type === "lecture" ? "Lecture" : "Conversation"} {t.date && {t.date}} {t.place && ( {t.place} )} {t.reference && ( {t.reference} )} {t.durationMinutes && t.durationMinutes > 0 && ( {t.durationMinutes} min )}
{/* Top nav */} {/* Audio + Participants row */}
{/* Participants */} {t.participants.length > 0 && ( <>
Participants:
{t.participants.map((p, i) => ( {p} ))}
)} {/* Play Audio button */} {t.audioUrl && (
)}
{/* Transcription content */} {t.content.length === 0 ? (

No transcription available

This recording has not been transcribed into text.

) : (
{t.content.map((block, i) => ( ))}
)} {/* Bottom nav */}
); } function ContentBlockView({ block, }: { block: { text: string; format: string; alignment: string; speaker: string | null; }; }) { const isVerse = block.format === "verse"; const isQuote = block.format === "quote"; const isCenter = block.alignment === "center"; const className = cn( "text-base leading-relaxed", isVerse && "text-center italic my-4", isQuote && "border-l-2 border-primary/30 pl-4 text-muted-foreground italic", !isVerse && !isQuote && isCenter && "text-center", ); return (
{block.speaker && ( {block.speaker}: )}
); } function TranscriptionNav({ prev, next, }: { prev: { slug: string; name: string } | null; next: { slug: string; name: string } | null; }) { return (
{prev ? ( {prev.name} Previous ) : (
)} {next ? ( {next.name} Next ) : (
)}
); }