diff --git a/package-lock.json b/package-lock.json index b995e1c..b599fd1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,6 +23,7 @@ "deepmerge": "^4.3.1", "lucide-react": "^0.427.0", "next": "14.2.5", + "next-google-adsense": "^1.0.12", "next-intl": "^3.17.2", "next-themes": "^0.3.0", "nextjs-toploader": "^1.6.12", @@ -10202,6 +10203,18 @@ } } }, + "node_modules/next-google-adsense": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/next-google-adsense/-/next-google-adsense-1.0.12.tgz", + "integrity": "sha512-fAS+OEgxaA06fxje/x+JzO395pwFm8wYPho0obfxADovoI3HSSaMucI68pDmsCakBEY+TKhsELrqKAx0qqs9EA==", + "bin": { + "create-ads-txt": "bin/cli.mjs" + }, + "peerDependencies": { + "next": ">=11.0.0", + "react": ">=17.0.0" + } + }, "node_modules/next-intl": { "version": "3.17.2", "resolved": "https://registry.npmjs.org/next-intl/-/next-intl-3.17.2.tgz", diff --git a/package.json b/package.json index 4be5d69..eff50e4 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "deepmerge": "^4.3.1", "lucide-react": "^0.427.0", "next": "14.2.5", + "next-google-adsense": "^1.0.12", "next-intl": "^3.17.2", "next-themes": "^0.3.0", "nextjs-toploader": "^1.6.12", diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx index 548706e..eebcfbf 100644 --- a/src/app/[locale]/layout.tsx +++ b/src/app/[locale]/layout.tsx @@ -1,4 +1,5 @@ +import { GoogleAdSenseClient } from "@/components/shared/GoogleAdSense"; import { appConfig, type LocaleType } from "@/config"; import getRequestConfig from "@/i18n"; import { cn, createAlternates } from "@/lib/utils"; @@ -69,6 +70,7 @@ export default async function RootLayout({ {appConfig.gaId && } + ); } diff --git a/src/components/shared/GoogleAdSense.tsx b/src/components/shared/GoogleAdSense.tsx new file mode 100644 index 0000000..dbfa58a --- /dev/null +++ b/src/components/shared/GoogleAdSense.tsx @@ -0,0 +1,10 @@ +"use client"; + +import { GoogleAdSense } from "next-google-adsense"; + +export function GoogleAdSenseClient() { + if(process.env.NEXT_PUBLIC_ADSENSE_PUBLISHER_ID){ + return + } + return null +} \ No newline at end of file diff --git a/src/config.ts b/src/config.ts index 70c4317..cfbd8ca 100644 --- a/src/config.ts +++ b/src/config.ts @@ -9,7 +9,7 @@ export const appConfig = { appRootDomain: "fontgenerator.dev", appName: "FontGenerator", appDescription: "font-generator", - gaId: process.env.NEXT_PUBLIC_GA_ID || 'G-GEKRPVPFPD', + gaId: process.env.NEXT_PUBLIC_GA_ID, i18n: { locales, defaultLocale,