"use client"; import Image from "next/legacy/image"; import Link from "next/link"; import { Swiper, SwiperSlide } from "swiper/react"; import { Autoplay } from "swiper/modules"; import "swiper/swiper-bundle.css"; import { useLatestPosts } from "@/lib/hooks/useBlog"; import { getValidImageUrl, getValidImageAlt, FALLBACK_IMAGES } from "@/lib/imageUtils"; const HomeLatestPost = () => { const { posts, loading, error } = useLatestPosts(12); // Get 12 latest posts return (

Latest Insights

View All Insights
{loading ? (
Loading...

Loading insights...

) : error ? (

Error loading insights. Please try again later.

) : posts.length === 0 ? (

No insights available yet.

) : (
3} roundLengths={true} modules={[Autoplay]} autoplay={{ delay: 5000, disableOnInteraction: false, pauseOnMouseEnter: true, }} className="tp-lp-slider" > {posts.map((post) => (
{getValidImageAlt(post.title)}

{post.author_name || 'Admin'}

{new Date(post.published_at || post.created_at).toLocaleDateString('en-US', { day: 'numeric', month: 'short', year: 'numeric' })}

{post.title}
))}
)}
); }; export default HomeLatestPost;