"use client";
import Link from "next/link";
import Image from "next/image";
import { ChevronLeft, ImageIcon } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Container } from "@/components/container";
import { getFeaturedImageUrl, type WpPost } from "@/lib/wp-api";
import { formatDateShamsi } from "@/lib/format-date";
import { layout } from "@/lib/layout";
import { cn } from "@/lib/utils";
import { type } from "@/lib/typography";
function stripHtml(html: string): string {
return html.replace(/<[^>]*>/g, "").trim();
}
/** کارت با تصویر بهصورت پسزمینه و عنوان + توضیح در پایین با overlay */
function PostCard({
post,
size = "default",
}: {
post: WpPost;
size?: "large" | "default";
}) {
const excerpt =
stripHtml(post.excerpt.rendered) ||
stripHtml(post.content.rendered).slice(0, size === "large" ? 280 : 120);
const date = post.date ? formatDateShamsi(post.date) : null;
const authorName = post._embedded?.author?.[0]?.name ?? null;
const thumbnailUrl = getFeaturedImageUrl(post, size === "large" ? "medium_large" : "medium");
const href = "#";
return (
{/* پسزمینه: تصویر تمام کارت */}
{thumbnailUrl ? (
{excerpt}
{caption}
مطالب بیشتر در دانشنامه