Add ads to the homepage for desktop users

Introduce a new `InlineAd` component and integrate it into the `NetflixGrid` to display ads after every second category and at the end of the homepage on desktop.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 401e2ec0-e00d-4f10-9d0e-60f3d479f9a5
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/60d372ff-2c10-46c7-b01b-10c3435136b0/401e2ec0-e00d-4f10-9d0e-60f3d479f9a5/pBMh1vD
This commit is contained in:
sebastjanartic 2025-09-28 19:51:00 +00:00
parent fcfb0ab68e
commit 40e1aab3d0
3 changed files with 58 additions and 6 deletions

View File

@ -31,6 +31,10 @@ externalPort = 3000
localPort = 35987
externalPort = 3003
[[ports]]
localPort = 39735
externalPort = 4200
[env]
PORT = "5000"

View File

@ -0,0 +1,38 @@
import { useEffect, useRef } from 'react';
export default function InlineAd() {
const adRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const initializeAd = () => {
const insElement = adRef.current?.querySelector('ins');
if (!insElement || insElement.dataset.adsbygoogleStatus === 'done') return;
try {
// @ts-ignore
(window.adsbygoogle = window.adsbygoogle || []).push({});
} catch (error) {
console.error('Inline AdSense initialization error:', error);
}
};
// Initialize the ad immediately
initializeAd();
}, []);
return (
<div className="w-full bg-bunny-dark hidden lg:flex justify-center py-4 my-8" ref={adRef}>
{/* Desktop Only: 1200x90px Inline Ad */}
<ins
className="adsbygoogle"
style={{
display: 'inline-block',
width: '1200px',
height: '90px'
}}
data-ad-client="ca-pub-4465464714854276"
data-ad-slot="8632735961"
/>
</div>
);
}

View File

@ -4,6 +4,7 @@ import { type Video } from "@shared/schema";
import VideoCard from "./video-card";
import BunnyVideoModal from "./bunny-video-modal";
import MobileInlineAd from "./MobileInlineAd";
import InlineAd from "./InlineAd";
import { Button } from "@/components/ui/button";
import { ChevronLeft, ChevronRight } from "lucide-react";
@ -179,14 +180,23 @@ export default function NetflixGrid({ videos, isLoading }: NetflixGridProps) {
<>
<div className="space-y-4">
{categories.map((category, categoryIndex) => (
<div key={categoryIndex} className={`${categoryIndex === 0 ? 'mt-2 mb-4' : 'mb-4'}`}>
<CategoryRow
category={category}
onVideoClick={handleVideoClick}
hideScrollButtons={false}
/>
<div key={categoryIndex}>
<div className={`${categoryIndex === 0 ? 'mt-2 mb-4' : 'mb-4'}`}>
<CategoryRow
category={category}
onVideoClick={handleVideoClick}
hideScrollButtons={false}
/>
</div>
{/* Add inline ad after every second category (categoryIndex 1, 3, 5...) */}
{categoryIndex > 0 && (categoryIndex + 1) % 2 === 0 && (
<InlineAd />
)}
</div>
))}
{/* Add final ad after all categories */}
<InlineAd />
</div>
<BunnyVideoModal