This commit is contained in:
knuthtimo-lab 2026-01-25 22:28:47 +01:00
parent 702e2710de
commit 54c3652c99
4 changed files with 48 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import type { Metadata } from 'next';
import AdBanner from '@/components/ads/AdBanner';
import '@/styles/globals.css';
import { Providers } from '@/components/Providers';
import MarketingLayout from './MarketingLayout';
@ -61,6 +62,15 @@ export default function MarketingGroupLayout({
<MarketingLayout>
{children}
</MarketingLayout>
{/* Global Marketing Ad - Exclusions handled in AdBanner */}
<div className="container mx-auto px-4 sm:px-6 lg:px-8 max-w-7xl pb-8">
<AdBanner
dataAdSlot="2607110637"
dataAdFormat="auto"
fullWidthResponsive={true}
className="bg-slate-50 rounded-xl p-4 border border-slate-100"
/>
</div>
</>
);
}

View File

@ -19,7 +19,7 @@ export default function ToolsLayout({
{/* AdBanner handles its own visibility - only shows when an ad is filled */}
<div className="container mx-auto px-4 sm:px-6 lg:px-8 max-w-7xl pb-8">
<AdBanner
dataAdSlot="1234567890" // Placeholder
dataAdSlot="2607110637" // Anzeige 1
dataAdFormat="auto"
fullWidthResponsive={true}
className="bg-slate-50 rounded-xl p-4 border border-slate-100"

View File

@ -51,6 +51,8 @@ export const metadata: Metadata = {
},
};
import AdBanner from '@/components/ads/AdBanner'; // Import AdBanner
export default function MarketingDeGroupLayout({
children,
}: {
@ -72,6 +74,16 @@ export default function MarketingDeGroupLayout({
/>
<MarketingDeLayout>
{children}
{/* Global Marketing Ad - Exclusions handled in AdBanner */}
<div className="container mx-auto px-4 sm:px-6 lg:px-8 max-w-7xl pb-8">
<AdBanner
dataAdSlot="2607110637"
dataAdFormat="auto"
fullWidthResponsive={true}
className="bg-slate-50 rounded-xl p-4 border border-slate-100"
/>
</div>
</MarketingDeLayout>
</Providers>
</Suspense>

View File

@ -3,6 +3,8 @@
import { useEffect, useState, useRef } from 'react';
import { useSession } from 'next-auth/react';
import { usePathname } from 'next/navigation';
interface AdBannerProps {
dataAdSlot: string;
dataAdFormat?: string;
@ -17,9 +19,30 @@ export default function AdBanner({
className = '',
}: AdBannerProps) {
const { data: session, status } = useSession();
const pathname = usePathname();
const adRef = useRef<HTMLModElement>(null);
const [adFilled, setAdFilled] = useState(false);
// Paths where ads should NOT be shown
const excludedPaths = [
'/', // English Home
'/de', // German Home
'/qr-code-erstellen', // German Landing
'/contact', // Contact
'/about', // About
'/legal', // Legal pages
'/privacy',
'/terms',
'/cookie-policy',
'/impressum',
];
// Check if current path matches strictly or starts with excluded path (for nested legal/blog pages if needed, though mostly exact matches here)
const shouldExclude = excludedPaths.some(path => {
if (path === '/') return pathname === '/';
return pathname === path || pathname?.startsWith(`${path}/`);
});
// Check if user has a paid plan
const isPaidUser = session?.user && (
session.user.plan === 'PRO' ||
@ -27,6 +50,8 @@ export default function AdBanner({
session.user.plan === 'LIFETIME'
);
if (shouldExclude) return null;
useEffect(() => {
// Don't load if loading session or if user is paid
if (status === 'loading' || isPaidUser) return;