import { Button } from "@/components/ui/button" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { ArrowLeft, PlayCircle, History, Calendar, Trophy, Youtube, Star } from "lucide-react" import Link from "next/link" import { notFound } from "next/navigation" import { Badge } from "@/components/ui/badge" import { getApiUrl } from "@/lib/api-config" import { CommentSection } from "@/components/social/comment-section" import { EntityRating } from "@/components/social/entity-rating" import { EntityReviews } from "@/components/reviews/entity-reviews" import { SocialWrapper } from "@/components/social/social-wrapper" import { PerformanceList } from "@/components/songs/performance-list" import { SongEvolutionChart } from "@/components/songs/song-evolution-chart" import { YouTubeEmbed } from "@/components/ui/youtube-embed" import { VERTICALS } from "@/config/verticals" // Helper to validate valid verticals for SSG export function generateStaticParams() { return VERTICALS.map((v) => ({ vertical: v.slug, })) } async function getSong(id: string) { try { const res = await fetch(`${getApiUrl()}/songs/${id}`, { cache: 'no-store' }) if (!res.ok) return null return res.json() } catch (e) { console.error(e) return null } } // Fetch cross-band versions of this song via SongCanon async function getRelatedVersions(songId: number) { try { const res = await fetch(`${getApiUrl()}/canon/song/${songId}/related`, { next: { revalidate: 60 } }) if (!res.ok) return [] return res.json() } catch { return [] } } // Get top rated performances for "Heady Version" leaderboard function getHeadyVersions(performances: any[]) { if (!performances || performances.length === 0) return [] return [...performances] .filter(p => p.avg_rating && p.rating_count > 0) .sort((a, b) => b.avg_rating - a.avg_rating) .slice(0, 5) } export default async function VerticalSongDetailPage({ params }: { params: Promise<{ vertical: string, slug: string }> }) { const { vertical, slug } = await params // Verify vertical exists (optional, could just let 404 handle it if song logic doesn't care) const validVertical = VERTICALS.find(v => v.slug === vertical) if (!validVertical) notFound() const song = await getSong(slug) if (!song) { notFound() } const headyVersions = getHeadyVersions(song.performances || []) const topPerformance = headyVersions[0] // Fetch cross-band versions const relatedVersions = await getRelatedVersions(song.id) return (
No video available
{topPerformance.show?.date ? new Date(topPerformance.show.date).toLocaleDateString() : "Unknown Date"}
{topPerformance.show?.venue?.name || "Unknown Venue"}
This song is performed by {relatedVersions.length + 1} different bands
{version.vertical_name}
{version.title}