Improve ad placement and fix display issues on the homepage

Modify ad insertion logic on the homepage to prevent ads from appearing in the same row and update image URLs in the gallery data.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 517dfa7b-26ac-463d-a6e1-a58c6df97188
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: e238672d-f0b8-42f8-b206-9c933e38a0b7
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
This commit is contained in:
sebastjanartic 2026-03-02 16:55:42 +00:00
parent 1ece209d7f
commit 94a970eb4d
5 changed files with 541 additions and 540 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -499,27 +499,28 @@ export default function Home() {
items.push({ type: "article", key: `a-${shuffled[ai].id}`, article: shuffled[ai++] }); items.push({ type: "article", key: `a-${shuffled[ai].id}`, article: shuffled[ai++] });
} }
const adPositions = [3, 9, 17, 23];
let adIdx = 0;
for (const pos of adPositions) {
if (pos <= items.length) {
items.splice(pos, 0, { type: "ad", key: `ad-${adIdx++}` });
}
}
const remainder = items.length % 4; const remainder = items.length % 4;
if (remainder > 0 && shuffled.length > 0) { if (remainder > 0 && shuffled.length > 0) {
let fill = 0; let fill = 0;
const usedIds = new Set(items.filter(i => i.article).map(i => i.article!.id));
const fillPool = shuffled.filter(a => !usedIds.has(a.id));
while (items.length % 4 !== 0) { while (items.length % 4 !== 0) {
const src = fillPool.length > 0 ? fillPool : shuffled; const art = shuffled[fill % shuffled.length];
const art = src[fill % src.length];
items.push({ type: "article", key: `fill-${fill}`, article: art }); items.push({ type: "article", key: `fill-${fill}`, article: art });
fill++; fill++;
} }
} }
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}` };
}
}
});
return items; return items;
}, [shuffled, widgets]); }, [shuffled, widgets]);

File diff suppressed because it is too large Load Diff