import { Clock, FileText } from 'lucide-react'; import { Link } from 'react-router-dom'; import type { Article } from '../../types'; import { cn } from '../../lib/utils'; import { AuthorAvatar } from './AuthorAvatar'; import { CategoryBadge } from './CategoryBadge'; const WORDS_PER_MINUTE = 200; /** Estimate reading time in minutes (minimum 1). */ export function getReadTime(content: string): number { const words = content.trim().split(/\s+/).filter(Boolean).length; return Math.max(1, Math.round(words / WORDS_PER_MINUTE)); } function formatPublished(value: Article['createdAt']): string { const date = value instanceof Date ? value : new Date(value); if (Number.isNaN(date.getTime())) return ''; return date.toLocaleDateString('en-GB', { day: 'numeric', month: 'short', year: 'numeric' }); } export interface ArticleCardProps { article: Article; className?: string; } /** * Reusable article preview: thumbnail placeholder, category badge, title, * excerpt, author (via AuthorAvatar) and estimated read time. Links to the * article detail route via react-router-dom. */ export function ArticleCard({ article, className }: ArticleCardProps) { const author = article.author ?? { id: article.authorId, name: 'Unknown author', email: '' }; return (
{/* Thumbnail placeholder (images arrive with a later milestone) */}
); } export default ArticleCard;