import React from 'react'; import Link from 'next/link'; import { notFound } from 'next/navigation'; import { ArrowLeft, Share2, Play, Calendar, User, Building2, MapPin, ArrowRight } from 'lucide-react'; import { sanitizeHTML } from '../../../lib/sanitize'; import { prisma } from '../../../lib/prisma'; import { InterviewType } from '@prisma/client'; import LightboxImage from '@/components/LightboxImage'; import BlogShareButtons from '../../../components/BlogShareButtons'; import { Metadata } from 'next'; interface Props { params: Promise<{ id: string }>; } export async function generateMetadata({ params }: Props): Promise { const { id } = await params; const now = new Date(); const interview = await prisma.interview.findFirst({ where: { OR: [{ id }, { slug: id }], publishedAt: { lte: now }, status: 'PUBLISHED' } }); const event = !interview ? await prisma.event.findFirst({ where: { OR: [{ id }, { slug: id }], publishedAt: { lte: now }, status: 'PUBLISHED' } }) : null; const item = interview || event; if (!item) return { title: 'Contenu non trouvé' }; const title = (item as any).metaTitle || item.title; const description = (item as any).metaDescription || (item as any).excerpt || (item as any).description; return { title, description, keywords: (item as any).tags || [], openGraph: { title, description, images: [(item as any).thumbnailUrl], } }; } export default async function AfroLifeDetailPage({ params }: Props) { const { id } = await params; const now = new Date(); // 1. Try to find an interview const interview = await prisma.interview.findFirst({ where: { OR: [{ id }, { slug: id }], publishedAt: { lte: now }, status: 'PUBLISHED' } }); // 2. If not found, try to find an event const event = !interview ? await prisma.event.findFirst({ where: { OR: [{ id }, { slug: id }], publishedAt: { lte: now }, status: 'PUBLISHED' } }) : null; if (!interview && !event) { notFound(); } const item = interview || event; const isEvent = !!event; // Helper to get YouTube embed URL const getEmbedUrl = (url: string) => { const regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/; const match = url.match(regExp); return (match && match[2].length === 11) ? `https://www.youtube.com/embed/${match[2]}` : null; }; const isVideo = !isEvent && (interview as any).type === InterviewType.VIDEO; return (
Retour à Afro Life
{/* Header Info */}
{isEvent ? 'Événement' : (isVideo ? 'Interview Vidéo' : 'Grand Entretien')}

{item!.title}

{/* Tags */} {item && (item as any).tags && (item as any).tags.length > 0 && (
{(item as any).tags.map((tag: string) => ( #{tag} ))}
)}
{!isEvent ? ( <>
{(interview as any).guestName} | {(interview as any).role}
{(interview as any).companyName}
) : (
{(event as any).location}
)}
{new Date(item!.date).toLocaleDateString('fr-FR', { day: 'numeric', month: 'long', year: 'numeric' })}
{/* Main Content Area en pleine largeur sur mobile */} {isVideo ? (
{(interview as any).videoUrl ? ( ) : (

Vidéo non disponible

)}
) : (
)} {/* Description / Article Content / Event Content */}
{isEvent ? (
) : ( !isVideo && (interview as any).content ? (
) : (

{(interview as any).excerpt}

) )}
{/* Event Link Action */} {isEvent && (event as any).link && (
Participer à l'événement
)} {/* Footer Actions / Partage */}

Partager {isEvent ? "cet événement" : "cette interview"}

); }