From 62db495bd3bb5a4fcf5538cbd7ec6e0fefc88d9a Mon Sep 17 00:00:00 2001 From: Anthony Ettinger Date: Wed, 21 Oct 2026 06:50:29 +0000 Subject: [PATCH] Strip in-body ad units from autoblog post HTML Autoblog content_html embeds its own banner_728x90 data-cp-ad slot and ad.js loader, giving posts a second, non-text_link unit. Drop them at render so each post shows only the one low-profile AdUnit. Co-Authored-By: Claude Opus 5.5 --- sites/sh1pt.com/app/blog/[slug]/page.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sites/sh1pt.com/app/blog/[slug]/page.tsx b/sites/sh1pt.com/app/blog/[slug]/page.tsx index f38965df..25c87bbc 100644 --- a/sites/sh1pt.com/app/blog/[slug]/page.tsx +++ b/sites/sh1pt.com/app/blog/[slug]/page.tsx @@ -5,6 +5,16 @@ import AdUnit from '../../components/AdUnit'; 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(/]*\bdata-cp-ad\b[^>]*>\s*<\/div>\s*/gi, '') + .replace(/]*\/api\/ads\/frame[^>]*>\s*<\/iframe>\s*/gi, '') + .replace(/]*crawlproof\.com\/ad\.js[^>]*>\s*<\/script>\s*/gi, ''); +} + export async function generateMetadata({ params, }: { @@ -75,7 +85,7 @@ export default async function BlogPostPage({ // 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) }} /> ) : (