From 74d93d892058f7a9fcc03a50bfe0e4e24ff7fdf6 Mon Sep 17 00:00:00 2001
From: torn4dom4n <27698189+torn4dom4n@users.noreply.github.com>
Date: Sat, 18 Jul 2026 17:39:28 +0000
Subject: [PATCH 1/2] Remove Google Adsense component, script, and references
- Delete app/components/Adsense.tsx
- Remove Adsense import and usage from mdx-components.tsx
- Remove Adsense component from app/[[...slug]]/page.tsx
- Remove Adsense script loader and unused imports from app/layout.tsx
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
---
app/[[...slug]]/page.tsx | 2 --
app/components/Adsense.tsx | 43 --------------------------------------
app/layout.tsx | 12 -----------
mdx-components.tsx | 2 --
4 files changed, 59 deletions(-)
delete mode 100644 app/components/Adsense.tsx
diff --git a/app/[[...slug]]/page.tsx b/app/[[...slug]]/page.tsx
index 38a9bce..a19b466 100644
--- a/app/[[...slug]]/page.tsx
+++ b/app/[[...slug]]/page.tsx
@@ -6,7 +6,6 @@ import {
} from "fumadocs-ui/page";
import type { Metadata } from "next";
import { notFound } from "next/navigation";
-import Adsense from "@/app/components/Adsense";
import { source } from "@/lib/source";
import { useMDXComponents } from "@/mdx-components";
@@ -26,7 +25,6 @@ export default async function Page(props: {
{page.data.description}
-
);
diff --git a/app/components/Adsense.tsx b/app/components/Adsense.tsx
deleted file mode 100644
index 90a55d0..0000000
--- a/app/components/Adsense.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-"use client";
-
-import { usePathname } from "next/navigation";
-import { useEffect } from "react";
-
-interface AdsenseProps {
- adSlot?: string;
-}
-
-export default function Adsense({ adSlot }: AdsenseProps) {
- const pathname = usePathname();
- const adClient =
- process.env.NEXT_PUBLIC_ADSENSE_CLIENT || "ca-pub-2837724975096238";
-
- useEffect(() => {
- if (!adClient) return;
-
- try {
- // @ts-expect-error
- const ads = window.adsbygoogle || [];
- // @ts-expect-error
- window.adsbygoogle = ads;
- ads.push({});
- } catch (err) {
- console.error("Adsense push error:", err);
- }
- }, [pathname, adClient]);
-
- if (!adClient) return null;
-
- return (
-
-
-
- );
-}
diff --git a/app/layout.tsx b/app/layout.tsx
index 48a5971..980213c 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -1,7 +1,6 @@
import "./globals.css";
import { RootProvider } from "fumadocs-ui/provider/next";
import { Inter } from "next/font/google";
-import Script from "next/script";
import type { ReactNode } from "react";
const inter = Inter({
@@ -18,22 +17,11 @@ export const metadata = {
};
export default function Layout({ children }: { children: ReactNode }) {
- const adClient =
- process.env.NEXT_PUBLIC_ADSENSE_CLIENT || "ca-pub-2837724975096238";
-
return (
{children}
- {adClient && (
-
- )}
);
diff --git a/mdx-components.tsx b/mdx-components.tsx
index e75fb25..402a723 100644
--- a/mdx-components.tsx
+++ b/mdx-components.tsx
@@ -3,7 +3,6 @@ import { Step, Steps } from "fumadocs-ui/components/steps";
import defaultComponents from "fumadocs-ui/mdx";
import type { MDXComponents } from "mdx/types";
import NextImage, { type ImageProps } from "next/image";
-import Adsense from "@/app/components/Adsense";
export function useMDXComponents(components: MDXComponents): MDXComponents {
return {
@@ -11,7 +10,6 @@ export function useMDXComponents(components: MDXComponents): MDXComponents {
Callout,
Steps,
Step,
- Adsense,
Image: (props: ImageProps) => (
Date: Sat, 18 Jul 2026 17:45:23 +0000
Subject: [PATCH 2/2] Remove Adsense client component and references while
keeping the script
- Delete app/components/Adsense.tsx client component
- Remove reference and import of Adsense in mdx-components.tsx
- Remove reference and import of Adsense in app/[[...slug]]/page.tsx
- Keep Google AdSense global script loader and env variable config intact in app/layout.tsx
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
---
app/layout.tsx | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/app/layout.tsx b/app/layout.tsx
index 980213c..48a5971 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -1,6 +1,7 @@
import "./globals.css";
import { RootProvider } from "fumadocs-ui/provider/next";
import { Inter } from "next/font/google";
+import Script from "next/script";
import type { ReactNode } from "react";
const inter = Inter({
@@ -17,11 +18,22 @@ export const metadata = {
};
export default function Layout({ children }: { children: ReactNode }) {
+ const adClient =
+ process.env.NEXT_PUBLIC_ADSENSE_CLIENT || "ca-pub-2837724975096238";
+
return (
{children}
+ {adClient && (
+
+ )}
);