From 0f1a0222a025292f428174e72355a33eb1cdad82 Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Sat, 28 Feb 2026 18:01:39 +0000 Subject: [PATCH] Add various ad placements throughout the website to monetize content Integrates AdSense for ads on the homepage, article pages, and video pages, including in-feed ads styled as article cards. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 413891e8-d784-4bea-b9f5-91a5a68316b4 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: b587b746-f67b-4539-9958-86999aee56de Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/413891e8-d784-4bea-b9f5-91a5a68316b4/igVW4lQ Replit-Helium-Checkpoint-Created: true --- client/index.html | 1 + client/src/components/adsense.tsx | 89 +++++++++++++++++++++++++++++++ client/src/pages/article.tsx | 3 ++ client/src/pages/home.tsx | 17 ++++-- client/src/pages/videos.tsx | 13 +++-- 5 files changed, 117 insertions(+), 6 deletions(-) create mode 100644 client/src/components/adsense.tsx diff --git a/client/index.html b/client/index.html index 8818917..9421193 100644 --- a/client/index.html +++ b/client/index.html @@ -9,6 +9,7 @@ + diff --git a/client/src/components/adsense.tsx b/client/src/components/adsense.tsx new file mode 100644 index 0000000..a92eec0 --- /dev/null +++ b/client/src/components/adsense.tsx @@ -0,0 +1,89 @@ +import { useEffect, useRef } from "react"; + +type AdFormat = "auto" | "fluid" | "rectangle" | "horizontal" | "vertical"; + +interface AdSenseProps { + slot: string; + format?: AdFormat; + responsive?: boolean; + className?: string; + style?: Record; + layout?: string; + layoutKey?: string; +} + +export default function AdSense({ + slot, + format = "auto", + responsive = true, + className = "", + style, + layout, + layoutKey, +}: AdSenseProps) { + const adRef = useRef(null); + const pushed = useRef(false); + + useEffect(() => { + if (pushed.current) return; + try { + const adsbygoogle = (window as any).adsbygoogle || []; + adsbygoogle.push({}); + pushed.current = true; + } catch (e) { + } + }, []); + + return ( +
+ +
+ ); +} + +export function ArticleCardAd() { + return ( +
+ +
+ ); +} + +export function InArticleAd() { + return ( + + ); +} + +export function SidebarAd() { + return ( +
+ +
+ ); +} diff --git a/client/src/pages/article.tsx b/client/src/pages/article.tsx index 7c88e1f..0b25826 100644 --- a/client/src/pages/article.tsx +++ b/client/src/pages/article.tsx @@ -8,6 +8,7 @@ import { Button } from "@/components/ui/button"; import { Skeleton } from "@/components/ui/skeleton"; import Header from "@/components/header"; import Footer from "@/components/footer"; +import { InArticleAd } from "@/components/adsense"; import DOMPurify from "dompurify"; import { useEffect } from "react"; @@ -214,6 +215,8 @@ export default function ArticlePage() { data-testid="article-content" /> + +