Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions apps/web/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Metadata } from 'next'
import { Footer, Header } from '@/components/chrome'
import { PitFooter } from '@/components/pit-footer'
import { AdUnit } from '@/components/ad-unit'
import { SITE } from '@/lib/site'
import './globals.css'
import Script from "next/script";
Expand Down Expand Up @@ -87,11 +88,9 @@ export default function RootLayout({ children }: { children: React.ReactNode })
<body className="flex min-h-screen flex-col">
<Header />
<main className="flex-1">
{/* One CrawlProof unit at the top of the content, never by the footer.
* No data-format: ad.js picks the size from the container width. */}
<div className="mx-auto max-w-6xl px-5 pt-6">
<div data-cp-ad="" data-slot="8d21a830-acfe-40ba-9d0d-0078d66ca479" />
</div>
{/* One low-profile CrawlProof unit at the top of the content, never by
* the footer, and none on the homepage. */}
<AdUnit />
{children}
</main>
<Footer />
Expand Down
30 changes: 30 additions & 0 deletions apps/web/components/ad-unit.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use client'

import { useEffect } from 'react'
import { usePathname } from 'next/navigation'

const AD_SLOT = '8d21a830-acfe-40ba-9d0d-0078d66ca479'

/**
* One CrawlProof unit at the top of the content, never by the footer: the
* low-profile text_link line (40px, fluid, its own "Sponsored" mark). The
* homepage carries no ad.
*/
export function AdUnit() {
const pathname = usePathname() ?? '/'
if (pathname === '/') return null
// Keyed by path: ad.js latches a filled unit, so each navigation gets a fresh one.
return <Unit key={pathname} />
}

function Unit() {
useEffect(() => {
// ad.js scans once at load; a unit mounted by client navigation asks again.
;(window as unknown as { crawlproofAds?: { scan?: () => void } }).crawlproofAds?.scan?.()
}, [])
return (
<div className="mx-auto max-w-6xl px-5 pt-2">
<div data-cp-ad="" data-slot={AD_SLOT} data-format="text_link" />
</div>
)
}
Loading