'use client'; import { useState, useEffect } from 'react'; import { useParams } from 'next/navigation'; import { Link } from '@/i18n/navigation'; import { motion } from 'framer-motion'; import { ArrowLeft, Calendar, User, Tag, Anchor } from 'lucide-react'; import { LandingHeader, LandingFooter } from '@/components/layout'; import { getBlogPost, type BlogPost } from '@/lib/api/blog'; const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:4000'; function resolveUrl(url: string | null | undefined): string | undefined { if (!url) return undefined; if (url.startsWith('http')) return url; return `${API_BASE_URL}${url}`; } function formatDate(dateStr: string): string { return new Date(dateStr).toLocaleDateString('fr-FR', { year: 'numeric', month: 'long', day: 'numeric', }); } const CATEGORY_LABELS: Record = { industry: 'Industrie', technology: 'Technologie', guides: 'Guides', news: 'Actualités', }; export default function BlogPostPage() { const params = useParams(); const slug = params?.slug as string; const [post, setPost] = useState(null); const [loading, setLoading] = useState(true); const [notFound, setNotFound] = useState(false); useEffect(() => { if (!slug) return; let cancelled = false; getBlogPost(slug) .then(p => { if (!cancelled) setPost(p); }) .catch(() => { if (!cancelled) setNotFound(true); }) .finally(() => { if (!cancelled) setLoading(false); }); return () => { cancelled = true; }; }, [slug]); if (loading) { return (
); } if (notFound || !post) { return (

Article introuvable

Cet article n'existe pas ou n'est pas encore publié.

Retour au blog
); } return (
{/* Hero */}
Retour au blog
{CATEGORY_LABELS[post.category] ?? post.category} {post.isFeatured && ( À la une )}

{post.title}

{post.excerpt}

{post.authorName}
{post.publishedAt && (
{formatDate(post.publishedAt)}
)} {post.tags.length > 0 && (
{post.tags.join(', ')}
)}
{/* Cover Image */} {post.coverImageUrl && (
)} {/* Content */}
{/* Tags */} {post.tags.length > 0 && (
{post.tags.map(tag => ( #{tag} ))}
)} {/* Back link */}
Retour au blog
); }