From fdf2c210ab56715ad0726f49b55ca76a9eed5f48 Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Mon, 2 Mar 2026 17:53:50 +0000 Subject: [PATCH] Place advertisements strategically between articles on the homepage Adjusted the home page layout logic to insert advertisements exclusively into rows containing only articles, specifically every second such row, ensuring they are not positioned adjacent to any widgets. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 517dfa7b-26ac-463d-a6e1-a58c6df97188 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 7dc1a9d6-6a76-4cb1-9abc-78b266bde261 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/517dfa7b-26ac-463d-a6e1-a58c6df97188/nFw7xof Replit-Helium-Checkpoint-Created: true --- client/src/pages/home.tsx | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/client/src/pages/home.tsx b/client/src/pages/home.tsx index bc4709c..0ad5a58 100644 --- a/client/src/pages/home.tsx +++ b/client/src/pages/home.tsx @@ -491,30 +491,20 @@ export default function Home() { } const totalRows = items.length / 4; - const widgetRowSet = new Set(); + let adCount = 0; + const articleOnlyRows: number[] = []; for (let row = 0; row < totalRows; row++) { const rowStart = row * 4; const rowItems = items.slice(rowStart, rowStart + 4); - if (rowItems.some((it) => it.type === "widget")) { - widgetRowSet.add(row); + if (rowItems.every((it) => it.type === "article")) { + articleOnlyRows.push(row); } } - - let adCount = 0; - for (let row = 0; row < totalRows && adCount < 4; row++) { - if (widgetRowSet.has(row)) continue; - if (widgetRowSet.has(row + 1)) continue; - if (widgetRowSet.has(row - 1)) continue; + for (let i = 0; i < articleOnlyRows.length && adCount < 4; i += 2) { + const row = articleOnlyRows[i]; const rowStart = row * 4; - const rowItems = items.slice(rowStart, rowStart + 4); - const articleIndices = rowItems - .map((it, ci) => (it.type === "article" ? ci : -1)) - .filter((ci) => ci >= 0); - if (articleIndices.length > 0) { - const col = articleIndices[0]; - items[rowStart + col] = { type: "ad", key: `ad-${adCount}` }; - adCount++; - } + items[rowStart] = { type: "ad", key: `ad-${adCount}` }; + adCount++; } return items;