diff --git a/src/components/ads/VerticalAdBanner.tsx b/src/components/ads/VerticalAdBanner.tsx index 3ee704b..187d1e7 100644 --- a/src/components/ads/VerticalAdBanner.tsx +++ b/src/components/ads/VerticalAdBanner.tsx @@ -30,7 +30,7 @@ export function VerticalAdBanner({ adSlot, ezoicPlacementId, position = "left" } return ( -
+
{isDevelopment ? ( ) : useEzoic ? ( diff --git a/src/components/ads/VerticalLeftBanner.tsx b/src/components/ads/VerticalLeftBanner.tsx index df967fb..30954c9 100644 --- a/src/components/ads/VerticalLeftBanner.tsx +++ b/src/components/ads/VerticalLeftBanner.tsx @@ -1,8 +1,22 @@ +"use client"; + +import { useState, useEffect } from "react"; + import { VerticalAdBanner } from "./VerticalAdBanner"; import { env } from "@/env"; export function VerticalLeftBanner() { + const [isDesktop, setIsDesktop] = useState(false); + + useEffect(() => { + const mq = window.matchMedia("(min-width: 1024px)"); + setIsDesktop(mq.matches); + const handler = (e: MediaQueryListEvent) => setIsDesktop(e.matches); + mq.addEventListener("change", handler); + return () => mq.removeEventListener("change", handler); + }, []); + const isCustom = env.NEXT_PUBLIC_AD_PROVIDER === "custom"; const hasAdSlot = env.NEXT_PUBLIC_VERTICAL_LEFT_BANNER_AD_SLOT; const hasEzoicPlacement = env.NEXT_PUBLIC_EZOIC_VERTICAL_LEFT_PLACEMENT_ID; @@ -11,6 +25,10 @@ export function VerticalLeftBanner() { return null; } + if (!isDesktop) { + return null; + } + return ( { + const mq = window.matchMedia("(min-width: 1024px)"); + setIsDesktop(mq.matches); + const handler = (e: MediaQueryListEvent) => setIsDesktop(e.matches); + mq.addEventListener("change", handler); + return () => mq.removeEventListener("change", handler); + }, []); + const isCustom = env.NEXT_PUBLIC_AD_PROVIDER === "custom"; const hasAdSlot = env.NEXT_PUBLIC_VERTICAL_RIGHT_BANNER_AD_SLOT; const hasEzoicPlacement = env.NEXT_PUBLIC_EZOIC_VERTICAL_RIGHT_PLACEMENT_ID; @@ -11,6 +25,10 @@ export function VerticalRightBanner() { return null; } + if (!isDesktop) { + return null; + } + return (