From c02d93cad8f28406a8e049d42c15d46e9c350519 Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Mon, 2 Mar 2026 17:53:02 +0000 Subject: [PATCH] Adjust ad placement to avoid displaying ads near content widgets Modify the logic for inserting advertisements to ensure they are not placed directly adjacent to any content widgets, preventing visual clutter and improving the user experience on the homepage. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 517dfa7b-26ac-463d-a6e1-a58c6df97188 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 469e25c3-fbc6-4f2b-8d23-588f0b8328dc 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 | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/client/src/pages/home.tsx b/client/src/pages/home.tsx index a17f91a..bc4709c 100644 --- a/client/src/pages/home.tsx +++ b/client/src/pages/home.tsx @@ -491,10 +491,20 @@ export default function Home() { } const totalRows = items.length / 4; - const adTargetRows = [1, 3, 5, 7]; + const widgetRowSet = new Set(); + 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); + } + } + let adCount = 0; - for (const row of adTargetRows) { - if (row >= totalRows) continue; + 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; const rowStart = row * 4; const rowItems = items.slice(rowStart, rowStart + 4); const articleIndices = rowItems