Skip to content

Commit

Permalink
add GoogleAdSense
Browse files Browse the repository at this point in the history
  • Loading branch information
seadfeng committed Nov 24, 2024
1 parent 50e8fd6 commit 2ef8053
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -69,6 +70,7 @@ export default async function RootLayout({
</NextIntlClientProvider>
{appConfig.gaId && <GoogleAnalytics gaId={appConfig.gaId} />}
</body>
<GoogleAdSenseClient />
</html>
);
}
10 changes: 10 additions & 0 deletions src/components/shared/GoogleAdSense.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"use client";

import { GoogleAdSense } from "next-google-adsense";

export function GoogleAdSenseClient() {
if(process.env.NEXT_PUBLIC_ADSENSE_PUBLISHER_ID){
return <GoogleAdSense />
}
return null
}
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2ef8053

Please sign in to comment.