Add advertisements to fill empty spaces on the homepage
Injects `ArticleCardAd` components into rows that do not contain widgets, ensuring a consistent four-column layout on the home page. Updates image URLs in `gallery-data.json`. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 1f7e7e89-a520-4970-9645-37daadc466dc Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 4f807297-9291-4e24-9592-e66ee067829b Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/1f7e7e89-a520-4970-9645-37daadc466dc/NJvOVoB Replit-Helium-Checkpoint-Created: true
This commit is contained in:
parent
2e640f9c88
commit
2d258f1523
@ -548,6 +548,16 @@ export default function Home() {
|
||||
}
|
||||
}
|
||||
|
||||
let adCount = 0;
|
||||
const totalRows = items.length / 4;
|
||||
for (let r = 0; r < totalRows; r++) {
|
||||
const rowStart = r * 4;
|
||||
const hasWidget = items.slice(rowStart, rowStart + 4).some((it) => it.type === "widget");
|
||||
if (!hasWidget) {
|
||||
items[rowStart + 3] = { type: "ad", key: `ad-row-${adCount++}` };
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}, [shuffled, widgets]);
|
||||
|
||||
@ -656,9 +666,11 @@ export default function Home() {
|
||||
{row.map((item) =>
|
||||
item.type === "widget"
|
||||
? <div key={item.key}>{item.widget!.el}</div>
|
||||
: item.article
|
||||
? <MediumCard key={item.key} article={item.article} focalPoints={focalPoints} />
|
||||
: null
|
||||
: item.type === "ad"
|
||||
? <div key={item.key} className="h-full" data-testid={`ad-grid-${item.key}`}><ArticleCardAd /></div>
|
||||
: item.article
|
||||
? <MediumCard key={item.key} article={item.article} focalPoints={focalPoints} />
|
||||
: null
|
||||
)}
|
||||
{ri === gridRows.length - 1 && widePickedArticles.length > 0 && (
|
||||
<div className="sm:col-span-2 lg:col-span-4 grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user