import { getCmsImageUrl } from '@/utils/image'; import Link from 'next/link'; interface BlogPreviewProps { data: { heading: string; subheading: string; ctaButton: { label: string; href: string; }; items: { title: string; excerpt: string; category: string; date: string; author: { name: string; avatar: string; }; comments: number; link: string; thumbnail: string; }[]; }; } const BlogPreview = ({ data }: BlogPreviewProps) => { const formatDate = (dateString: string) => { const date = new Date(dateString); return date.toLocaleDateString('en-US', { day: 'numeric', month: 'long', year: 'numeric' }); }; return (
{data.subheading}

{data.heading}

{data.ctaButton.label}
{data.items.map((item, index) => { const thumbUrl = getCmsImageUrl(item.thumbnail); return (
img {item.category}
Comment ({item.comments.toString().padStart(2, '0')}) _ {formatDate(item.date)}

{item.title}

{item.author.name.charAt(0).toUpperCase()}
By {item.author.name}
View Articles
); })}
); }; export default BlogPreview;