diff --git a/docs/src/components/Adsense/AddBanner.tsx b/docs/src/components/Adsense/AddBanner.tsx deleted file mode 100644 index 9552171..0000000 --- a/docs/src/components/Adsense/AddBanner.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import Script from "next/script"; - -interface AddBannerProps { - AdClient: string; - AdSlot: string; - AdFormat?: string; - FullWidthResponsive?: boolean; -} - -export default function AddBanner({ - AdClient, - AdSlot, - AdFormat = "auto", - FullWidthResponsive = true, -}: AddBannerProps) { - return ( - <> - - - - ); -} diff --git a/docs/src/components/Adsense/Adsbygoogle.tsx b/docs/src/components/Adsense/Adsbygoogle.tsx new file mode 100644 index 0000000..e3a44ac --- /dev/null +++ b/docs/src/components/Adsense/Adsbygoogle.tsx @@ -0,0 +1,22 @@ +"use client"; + +import { useEffect } from "react"; + +declare global { + interface Window { + adsbygoogle: any; + } +} + +interface AdsbygoogleProps { + NODE_ENV: string | undefined; +} + +export default function Adsbygoogle({ NODE_ENV }: AdsbygoogleProps) { + useEffect(() => { + NODE_ENV === "production" && + (window.adsbygoogle = window.adsbygoogle || []).push({}); + }, []); + + return <>; +} diff --git a/docs/src/components/Adsense/index.tsx b/docs/src/components/Adsense/index.tsx index 8656552..a9fcfac 100644 --- a/docs/src/components/Adsense/index.tsx +++ b/docs/src/components/Adsense/index.tsx @@ -1,4 +1,4 @@ -import Script from "next/script"; +import Adsbygoogle from "./Adsbygoogle"; interface AdsenseProps { GOOGLE_ADSENSE_CLIENT_ID: string | undefined; @@ -38,9 +38,7 @@ export function AddBanner({ data-ad-format={AdFormat} data-full-width-responsive={FullWidthResponsive} /> - + ); }