File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ const vars = [
1717 { name: ' PUBLIC_ADSENSE_SLOT_TOOL_FOOTER' , value: slotToolFooter },
1818 { name: ' PUBLIC_ADSENSE_SLOT_BLOG_INARTICLE' , value: slotBlogInArticle },
1919];
20+
21+ const allVarsSet = vars .every ((v ) => Boolean (v .value ));
2022---
2123
2224{ isDev && (
@@ -35,7 +37,9 @@ const vars = [
3537 ))}
3638 </div >
3739 <div class = " text-yellow-700 dark:text-yellow-300 mt-2 text-[10px]" >
38- Set vars in .env to see ad slots render.
40+ { allVarsSet
41+ ? ' Vars are set. Blank local ads usually mean AdSense returned no fill or was blocked.'
42+ : ' Set missing vars in .env to render ad slots.' }
3943 </div >
4044 </div >
4145)}
Original file line number Diff line number Diff line change @@ -33,13 +33,14 @@ const {
3333
3434const adsenseClient = import .meta .env .PUBLIC_ADSENSE_CLIENT ;
3535const adsEnabled = Boolean (adsenseClient );
36+ const isDev = import .meta .env .DEV ;
3637const isInArticleFluid = format === ' fluid' && layout === ' in-article' ;
3738const adStyle = isInArticleFluid ? ' display:block; text-align:center;' : ' display:block' ;
3839---
3940
4041{ adsEnabled && (
4142 <aside
42- class :list = { [' ad-slot block w-full overflow-hidden text-center' , className ]}
43+ class :list = { [' ad-slot relative block w-full overflow-hidden text-center' , isDev && ' min-h-32 ' , className ]}
4344 aria-label = " Advertisement"
4445 >
4546 <ins
@@ -51,8 +52,29 @@ const adStyle = isInArticleFluid ? 'display:block; text-align:center;' : 'displa
5152 data-ad-layout = { layout }
5253 data-full-width-responsive = { isInArticleFluid ? undefined : responsive ? ' true' : ' false' }
5354 ></ins >
55+ { isDev && (
56+ <div class = " dev-ad-placeholder pointer-events-none absolute inset-0 z-10 hidden min-h-32 items-center justify-center rounded-md border border-dashed border-yellow-300 bg-yellow-50/95 px-4 py-6 text-center text-xs text-yellow-900 dark:border-yellow-700 dark:bg-yellow-950/95 dark:text-yellow-100" >
57+ <div >
58+ <div class = " font-semibold" >Ad slot rendered</div >
59+ <div class = " mt-1" >
60+ Google returned no local ad fill or the request was blocked. Slot { slot } .
61+ </div >
62+ </div >
63+ </div >
64+ )}
5465 <script is :inline >
5566 (window.adsbygoogle = window.adsbygoogle || []).push({ } );
5667 </script >
5768 </aside >
5869)}
70+
71+ <style >
72+ .adsbygoogle:not([data-adsbygoogle-status]) + .dev-ad-placeholder,
73+ .adsbygoogle[data-ad-status='unfilled'] + .dev-ad-placeholder {
74+ display: flex;
75+ }
76+
77+ .adsbygoogle[data-ad-status='filled'] + .dev-ad-placeholder {
78+ display: none;
79+ }
80+ </style >
You can’t perform that action at this time.
0 commit comments