This commit is contained in:
Timo Knuth 2026-01-23 14:54:02 +01:00
parent 9c5f7beb91
commit f872fb64b2
4 changed files with 50 additions and 10 deletions

View File

@ -1,5 +1,4 @@
import type { Metadata } from 'next';
import Script from 'next/script';
import '@/styles/globals.css';
import { Providers } from '@/components/Providers';
import MarketingLayout from './MarketingLayout';
@ -63,12 +62,6 @@ export default function MarketingGroupLayout({
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(websiteSchema()) }}
/>
<Script
async
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-2782770414424875"
crossOrigin="anonymous"
strategy="lazyOnload"
/>
<MarketingLayout>
{children}
</MarketingLayout>

View File

@ -1,7 +1,6 @@
'use client';
import React from 'react';
import Script from 'next/script';
import AdBanner from '@/components/ads/AdBanner';
export default function ToolsLayout({
@ -11,8 +10,7 @@ export default function ToolsLayout({
}) {
return (
<div className="flex flex-col min-h-screen">
{/* AdSense script - only loads on tool pages */}
{/* AdSense script - now global in (marketing) layout */}
{/* AdSense script - managed by global AdSenseScript component */}
<div className="flex-grow relative">
{children}
</div>

View File

@ -2,6 +2,7 @@ import type { Metadata } from 'next';
import { Suspense } from 'react';
import '@/styles/globals.css';
import { Providers } from '@/components/Providers';
import AdSenseScript from '@/components/ads/AdSenseScript';
const isIndexable = process.env.NEXT_PUBLIC_INDEXABLE === 'true';
@ -56,6 +57,7 @@ export default function RootLayout({
<body className="font-sans">
<Suspense fallback={null}>
<Providers>
<AdSenseScript />
{children}
</Providers>
</Suspense>

View File

@ -0,0 +1,47 @@
'use client';
import Script from 'next/script';
import { usePathname } from 'next/navigation';
export default function AdSenseScript() {
const pathname = usePathname();
// Paths where ads should NOT be shown
const excludedPaths = [
'/', // English Home
'/de', // German Home
'/pricing', // Pricing Page
'/login', // Login
'/signup', // Signup
'/forgot-password', // Forgot Password
'/qr-code-erstellen', // German landing page
'/dashboard', // App Dashboard
'/settings', // App Settings
'/analytics', // App Analytics
'/qr', // QR Creation/Management
'/create', // Create Flow
];
// Check if current path starts with any excluded path
// We add '/' to excluded path to match exact path or subpaths,
// EXCEPT for root '/' which needs special handling
const shouldExclude = excludedPaths.some(path => {
if (path === '/') {
return pathname === '/';
}
return pathname === path || pathname?.startsWith(`${path}/`);
});
if (shouldExclude) {
return null;
}
return (
<Script
async
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-2782770414424875"
crossOrigin="anonymous"
strategy="lazyOnload"
/>
);
}