File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import CoverMedia from "@/components/cover-media";
2222import MoreHeader from "@/components/more-header" ;
2323import { BreadcrumbLinks } from "@/components/breadrumb-links" ;
2424import SponsorCard from "@/components/sponsor-card" ;
25+ import CarbonAdBanner from "@/components/carbon-ad-banner" ;
2526
2627type Props = {
2728 params : { slug : string } ;
@@ -109,11 +110,7 @@ export default async function PostPage({ params }: Props) {
109110 < hr className = "border-accent-2" />
110111 </ section >
111112 ) : (
112- < GoogleAdBanner
113- data-ad-slot = "4960900523"
114- data-full-width-responsive = "true"
115- data-ad-format = "auto"
116- />
113+ < CarbonAdBanner />
117114 ) }
118115 { post . content ?. length && (
119116 < PortableText
Original file line number Diff line number Diff line change @@ -139,12 +139,6 @@ export default async function RootLayout({
139139 < SpeedInsights />
140140 </ ThemeProvider >
141141 </ PlayerProvider >
142- < Script
143- async
144- src = { `https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${ process . env . NEXT_PUBLIC_GOOGLE_ADS_CLIENT_ID } ` }
145- strategy = "lazyOnload"
146- crossOrigin = "anonymous"
147- > </ Script >
148142 </ body >
149143 </ html >
150144 ) ;
Original file line number Diff line number Diff line change 1+ "use client"
2+ import { useEffect , useRef } from "react" ;
3+
4+ export default function CarbonAdBanner ( ) {
5+ const reference = useRef < HTMLDivElement > ( null ) ;
6+
7+ useEffect ( ( ) => {
8+ if ( ! reference . current ) return ;
9+ reference . current . innerHTML = "" ;
10+ const s = document . createElement ( "script" ) ;
11+ s . id = "_carbonads_js" ;
12+ s . src = `//cdn.carbonads.com/carbon.js?serve=CW7DCKJJ&placement=codingcatdev&format=cover` ;
13+ reference . current . appendChild ( s ) ;
14+ } , [ ] ) ;
15+ return < div className = "flex justify-center my-2" ref = { reference } /> ;
16+ }
You can’t perform that action at this time.
0 commit comments