diff --git a/attached_assets/image_1772307180177.png b/attached_assets/image_1772307180177.png new file mode 100644 index 0000000..ef37060 Binary files /dev/null and b/attached_assets/image_1772307180177.png differ diff --git a/client/src/pages/home.tsx b/client/src/pages/home.tsx index 3d944b7..d7e5e8d 100644 --- a/client/src/pages/home.tsx +++ b/client/src/pages/home.tsx @@ -203,9 +203,8 @@ function TopStoriesList({ articles }: { articles: Article[] }) { } function FeaturedCarousel({ articles, popular, galleryImages }: { articles: Article[]; popular?: Article[]; galleryImages?: GalleryImage[] }) { - const PAGES = 5; const hasGallery = galleryImages && galleryImages.length > 0; - const articlePages = Math.min(PAGES, Math.ceil(articles.length / 3)); + const articlePages = Math.min(5, Math.max(1, articles.length)); const total = articlePages + (hasGallery ? 1 : 0); const [page, setPage] = useState(0); const [paused, setPaused] = useState(false); @@ -225,14 +224,12 @@ function FeaturedCarousel({ articles, popular, galleryImages }: { articles: Arti let hero: Article | null = null; let side: Article[] = []; - if (!isGalleryPage) { - const start = page * 3; - const visible = articles.slice(start, start + 3); - while (visible.length < 3 && articles.length >= 3) { - visible.push(articles[visible.length % articles.length]); - } - hero = visible[0] || null; - side = visible.slice(1, 3); + if (!isGalleryPage && articles.length > 0) { + hero = articles[page % articles.length]; + side = [ + articles[(page * 2 + 1) % articles.length], + articles[(page * 2 + 2) % articles.length], + ]; } return (