import Link from "next/link"; import Image from "next/image"; import { ImageIcon, User } from "lucide-react"; import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card"; import { getFeaturedImageUrl, type WpPost } from "@/lib/wp-api"; import { formatDateShamsi } from "@/lib/format-date"; function stripHtml(html: string): string { return html.replace(/<[^>]*>/g, "").trim(); } export function BlogPostCard({ post }: { post: WpPost }) { const excerpt = stripHtml(post.excerpt.rendered) || stripHtml(post.content.rendered).slice(0, 160); const modifiedDate = post.modified ? formatDateShamsi(post.modified) : null; const authorName = post._embedded?.author?.[0]?.name ?? null; const thumbnailUrl = getFeaturedImageUrl(post, "medium"); return ( {thumbnailUrl ? (
) : (
)} {post.title.rendered}
{authorName && ( {authorName} )} {modifiedDate && ( )}

{excerpt}

); }