import { motion } from "motion/react"; import { ArrowUpRight, Loader2 } from "lucide-react"; import Button from "@/components/ui/Button"; import TextAnimation from "@/components/ui/TextAnimation"; import GridOrCarousel from "@/components/ui/GridOrCarousel"; import ImageOrVideo from "@/components/ui/ImageOrVideo"; import { useButtonClick } from "@/hooks/useButtonClick"; import useBlogPosts from "@/hooks/useBlogPosts"; type BlogItem = { category: string; title: string; excerpt: string; authorName: string; authorImageSrc: string; date: string; imageSrc: string; href?: string; onClick?: () => void; }; const BlogCardItem = ({ item }: { item: BlogItem }) => { const handleClick = useButtonClick(item.href, item.onClick); return ( {item.category} {item.title} {item.excerpt} {item.authorName} {item.date} ); }; type BlogSimpleCardsProps = { tag: string; title: string; description: string; primaryButton?: { text: string; href: string }; secondaryButton?: { text: string; href: string }; items?: BlogItem[]; }; const BlogSimpleCards = ({ tag, title, description, primaryButton, secondaryButton, items: itemsProp, }: BlogSimpleCardsProps) => { const { posts, isLoading } = useBlogPosts(); const isFromApi = posts.length > 0; const items = isFromApi ? posts.map((p) => ({ category: p.category, title: p.title, excerpt: p.excerpt, authorName: p.authorName, authorImageSrc: p.authorAvatar, date: p.date, imageSrc: p.imageSrc, onClick: p.onBlogClick, })) : itemsProp; if (isLoading && !itemsProp) { return ( ); } if (!items || items.length === 0) { return null; } return ( {tag} {(primaryButton || secondaryButton) && ( {primaryButton && } {secondaryButton && } )} {items.map((item, index) => ( ))} ); }; export default BlogSimpleCards;
{item.excerpt}