This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
"use client";
|
||||
|
||||
import Script from "next/script";
|
||||
|
||||
import { authClient } from "@/lib/auth/client";
|
||||
|
||||
const clientId = process.env.NEXT_PUBLIC_GOOGLE_ADSENSE_CLIENT_ID?.trim();
|
||||
|
||||
export function GoogleAdsense() {
|
||||
const { data: session, error, isPending } = authClient.useSession();
|
||||
|
||||
if (
|
||||
process.env.NODE_ENV !== "production" ||
|
||||
!clientId ||
|
||||
isPending ||
|
||||
error ||
|
||||
session
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Script
|
||||
id="google-adsense"
|
||||
src={`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${encodeURIComponent(clientId)}`}
|
||||
strategy="afterInteractive"
|
||||
crossOrigin="anonymous"
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user