feat(web): ad.network unit + claim meta on the home page (#247)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Anthony Ettinger 2026-10-19 06:00:10 -07:00 • committed by GitHub
parent c8da4cb4ab
commit d150717f90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 48 additions and 1 deletions

View file

@ -5,6 +5,8 @@ import { renderPageMarkup } from "@/lib/page-markup";
import { pageMetadata, specMetadata } from "@/lib/page-meta";
import { HomeInteractivity } from "@/components/home-interactivity";
import { siteFooterHtml } from "@/lib/site-footer";
import Script from "next/script";
import { AD_NETWORK_CODE } from "@/lib/ad-network";
// The legacy SPA served the same single page for every top-level path and just
// scrolled to the matching section. We preserve those URLs (they are canonical
@ -36,7 +38,8 @@ export async function generateMetadata({
const key = slug?.[0];
if (key && SPEC_SECTIONS.has(key)) return specMetadata(`/${key}`);
if (key && SITE_SECTIONS.has(key)) return pageMetadata(`/${key}`);
return pageMetadata("/");
if (key) return pageMetadata("/");
return { ...pageMetadata("/"), other: { "ad.network": AD_NETWORK_CODE } };
}
export default async function Page({
@ -56,6 +59,7 @@ export default async function Page({
<>
<div id="app" dangerouslySetInnerHTML={{ __html: renderPageMarkup(slug?.[0] ? `/${slug[0]}` : "/", footer) }} />
<HomeInteractivity />
{!slug?.length && <Script src="https://crawlproof.com/ad.js" strategy="afterInteractive" />}
</>
);
}

View file

@ -115,5 +115,22 @@ export function HomeInteractivity(): null {
};
}, []);
// The home page ad.network unit lives in the server-rendered markup, and
// crawlproof's ad.js scans once at DOMContentLoaded. A client-side visit to
// "/" (from /blog, say) re-renders the markup after that scan, so ask the
// loader to scan again, retrying briefly while the script is still loading.
useEffect(() => {
if (!document.querySelector("[data-ad-network]")) return;
let tries = 0;
const timer = window.setInterval(() => {
const ads = (window as { crawlproofAds?: { scan?: () => void } }).crawlproofAds;
if (ads?.scan || ++tries >= 20) {
window.clearInterval(timer);
ads?.scan?.();
}
}, 250);
return () => window.clearInterval(timer);
}, []);
return null;
}

View file

@ -0,0 +1,11 @@
// ad.network publisher claim for logicsrc.com. The <meta name="ad.network">
// tag (home page metadata) lets ad.network verify ownership from the
// server-rendered HTML; the aside is the home page unit, filled in place by
// crawlproof.com/ad.js. Blog pages keep their own CrawlProof slot (AdUnit).
export const AD_NETWORK_CODE = "xPEOavNsIGrivkMw";
export const HOME_AD_SLOT = "efda46e1-bbc3-42e7-8fd0-2640bdd8a90f";
/** The home page unit, placed between the hero and the first band. */
export function renderHomeAdHtml(): string {
return `<aside class="home-ad" data-ad-network="${AD_NETWORK_CODE}" data-cp-ad data-slot="${HOME_AD_SLOT}" data-format="banner_300x250"></aside>`;
}

View file

@ -7,6 +7,7 @@ import { renderInstallCommand } from "./install-command";
import { renderNavHtml } from "./nav";
import { renderCrumbsHtml } from "./crumbs";
import { FAMILIES, familyTree } from "./specs";
import { renderHomeAdHtml } from "./ad-network";
const schemas = [
{ name: "logicsrc-task", path: "packages/schemas/schemas/logicsrc-task.schema.json" },
@ -148,6 +149,7 @@ export function renderPageMarkup(path = "/", footer = ""): string {
<span><strong>3</strong>reference plugins</span>
</div>
</header>
${path === "/" ? renderHomeAdHtml() : ""}
<section class="band">
<div class="section-head">

View file

@ -1004,3 +1004,16 @@ pre {
color: #101418;
font-weight: 600;
}
/* Home page ad.network unit: collapsed until crawlproof's ad.js fills it. */
.home-ad {
display: flex;
justify-content: center;
height: 0;
overflow: hidden;
}
.home-ad[data-cp-filled] {
height: auto;
min-height: 266px;
margin: 8px 0 24px;
}