Skip to content
Merged
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
12 changes: 11 additions & 1 deletion sites/sh1pt.com/app/blog/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@

export const dynamic = 'force-dynamic';

// Autoblog bodies can carry their own ad slot (a banner [data-cp-ad] div plus
// the ad.js loader). The page already renders one low-profile AdUnit, so drop
// any in-body units to keep it at one text_link line per page.
function stripInlineAds(html: string): string {
return html
.replace(/<div\b[^>]*\bdata-cp-ad\b[^>]*>\s*<\/div>\s*/gi, '')
.replace(/<iframe\b[^>]*\/api\/ads\/frame[^>]*>\s*<\/iframe>\s*/gi, '')
.replace(/<script\b[^>]*crawlproof\.com\/ad\.js[^>]*>\s*<\/script>\s*/gi, '');
}

export async function generateMetadata({
params,
}: {
Expand Down Expand Up @@ -75,7 +85,7 @@
// content_html is rendered by the Crawlproof pipeline from
// sanitized markdown; we trust it because only service-role
// writes blog_posts and the source is authenticated by bearer.
dangerouslySetInnerHTML={{ __html: post.content_html }}
dangerouslySetInnerHTML={{ __html: stripInlineAds(post.content_html) }}
/>
) : (
<pre style={{ marginTop: 32, whiteSpace: 'pre-wrap' }}>
Expand Down
Loading