diff --git a/attached_assets/image_1772475024743.png b/attached_assets/image_1772475024743.png new file mode 100644 index 0000000..3766b42 Binary files /dev/null and b/attached_assets/image_1772475024743.png differ diff --git a/client/src/pages/home.tsx b/client/src/pages/home.tsx index aa2d971..253a749 100644 --- a/client/src/pages/home.tsx +++ b/client/src/pages/home.tsx @@ -483,15 +483,17 @@ export default function Home() { const totalRows = items.length / 4; const adRows = [1, 3, 5, 7]; - const adCols = [3, 1, 2, 0]; - adRows.forEach((row, i) => { - if (row < totalRows) { - const idx = row * 4 + adCols[i % adCols.length]; - if (items[idx] && items[idx].type === "article") { - items[idx] = { type: "ad", key: `ad-${i}` }; + let adCount = 0; + for (const row of adRows) { + if (row >= totalRows) continue; + const rowStart = row * 4; + for (let col = 3; col >= 0; col--) { + if (items[rowStart + col] && items[rowStart + col].type === "article") { + items[rowStart + col] = { type: "ad", key: `ad-${adCount++}` }; + break; } } - }); + } return items; }, [shuffled, widgets]);