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

@@ -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"
/>
);
}