Update featured carousel to display more articles dynamically
Adjust the featured carousel logic to dynamically display articles, ensuring all available articles are utilized for rotation and subsequent rows display remaining content. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 413891e8-d784-4bea-b9f5-91a5a68316b4 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 581a45cc-e662-4c38-a7e6-cbb2c4187079 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/413891e8-d784-4bea-b9f5-91a5a68316b4/RVXhOPb Replit-Helium-Checkpoint-Created: true
This commit is contained in:
parent
c6dc352a06
commit
a5caf0f5af
BIN
attached_assets/image_1772307180177.png
Normal file
BIN
attached_assets/image_1772307180177.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
@ -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 (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user