Improve AdSense ad rendering and initialization for better visibility
Update AdSenseAd component to ensure proper initialization and rendering with defined styles, improving ad slot visibility and user experience. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 45a1dcfc-f8a2-475a-a6b9-96fbb841dc27 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/60d372ff-2c10-46c7-b01b-10c3435136b0/45a1dcfc-f8a2-475a-a6b9-96fbb841dc27/dy0t7tj
This commit is contained in:
parent
39a2567ba9
commit
646f4f3843
4
.replit
4
.replit
@ -15,6 +15,10 @@ run = ["npm", "run", "start"]
|
||||
localPort = 5000
|
||||
externalPort = 80
|
||||
|
||||
[[ports]]
|
||||
localPort = 35163
|
||||
externalPort = 3000
|
||||
|
||||
[env]
|
||||
PORT = "5000"
|
||||
|
||||
|
||||
@ -21,16 +21,20 @@ export default function AdSenseAd({
|
||||
try {
|
||||
// Ensure adsbygoogle is loaded
|
||||
if (typeof window !== 'undefined') {
|
||||
console.log(`🎯 AdSense: Initializing ad slot ${adSlot}`);
|
||||
// @ts-ignore
|
||||
(window.adsbygoogle = window.adsbygoogle || []).push({});
|
||||
console.log(`✅ AdSense: Ad slot ${adSlot} pushed to queue`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('AdSense initialization error:', error);
|
||||
}
|
||||
}, []);
|
||||
}, [adSlot]);
|
||||
|
||||
const adStyle: React.CSSProperties = {
|
||||
display: 'block'
|
||||
display: 'block',
|
||||
minWidth: '300px',
|
||||
minHeight: '250px'
|
||||
};
|
||||
|
||||
if (adFormat !== 'auto' && width && height) {
|
||||
@ -41,8 +45,11 @@ export default function AdSenseAd({
|
||||
adStyle.height = 'auto';
|
||||
}
|
||||
|
||||
console.log(`📐 AdSense: Rendering ad slot ${adSlot} with style:`, adStyle);
|
||||
|
||||
return (
|
||||
<div className={`adsense-wrapper ${className}`} ref={adRef}>
|
||||
<div className={`adsense-wrapper ${className}`} ref={adRef} style={{ minHeight: '250px', background: 'rgba(255,255,255,0.05)', border: '1px solid rgba(255,255,255,0.1)', borderRadius: '8px', padding: '10px' }}>
|
||||
<div className="text-white text-xs opacity-50 mb-2">AdSense Slot: {adSlot}</div>
|
||||
<ins
|
||||
className="adsbygoogle"
|
||||
style={adStyle}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user