'use client'; import { useRef, useEffect } from 'react'; import Link from 'next/link'; import { useTranslations } from 'next-intl'; import { Article } from '@/lib/blog/types'; type props = { locale: string; articles: Article[]; }; export function ArticleList({ locale, articles }: props) { const ref = useRef(null); const t = useTranslations('blogPage'); useEffect(() => { const el = ref.current; if (!el) return; const observer = new IntersectionObserver( ([entry]) => { if (entry.isIntersecting) { el.querySelectorAll('.reveal').forEach((node, i) => { setTimeout(() => node.classList.add('visible'), i * 100); }); observer.unobserve(el); } }, { threshold: 0.05 } ); observer.observe(el); return () => observer.disconnect(); }, []); if (!articles.length) { return (

{t('noArticles')}

); } return (
{articles.map((article, i) => { const formatted = new Date(article.date).toLocaleDateString( locale === 'fr' ? 'fr-FR' : 'en-US', { year: 'numeric', month: 'long', day: 'numeric' } ); return (
{article.category} {article.readTime && ( <> {article.readTime} )}

{article.title}

{article.description}

{formatted}
{t('readArticle')}
); })}
); }