|
| 1 | +--- |
| 2 | +/** |
| 3 | + * Dev-only debug banner showing AdSense env var status. |
| 4 | + * Only renders in local development (import.meta.env.DEV). |
| 5 | + * Helps troubleshoot why ad slots aren't appearing locally. |
| 6 | + */ |
| 7 | +
|
| 8 | +const isDev = import.meta.env.DEV; |
| 9 | +const adsenseClient = import.meta.env.PUBLIC_ADSENSE_CLIENT; |
| 10 | +const slotToolInArticle = import.meta.env.PUBLIC_ADSENSE_SLOT_TOOL_INARTICLE; |
| 11 | +const slotToolFooter = import.meta.env.PUBLIC_ADSENSE_SLOT_TOOL_FOOTER; |
| 12 | +const slotBlogInArticle = import.meta.env.PUBLIC_ADSENSE_SLOT_BLOG_INARTICLE; |
| 13 | +
|
| 14 | +const vars = [ |
| 15 | + { name: 'PUBLIC_ADSENSE_CLIENT', value: adsenseClient }, |
| 16 | + { name: 'PUBLIC_ADSENSE_SLOT_TOOL_INARTICLE', value: slotToolInArticle }, |
| 17 | + { name: 'PUBLIC_ADSENSE_SLOT_TOOL_FOOTER', value: slotToolFooter }, |
| 18 | + { name: 'PUBLIC_ADSENSE_SLOT_BLOG_INARTICLE', value: slotBlogInArticle }, |
| 19 | +]; |
| 20 | +--- |
| 21 | + |
| 22 | +{isDev && ( |
| 23 | + <div class="fixed bottom-4 right-4 z-50 max-w-sm bg-yellow-50 dark:bg-yellow-900 border-2 border-yellow-300 dark:border-yellow-700 rounded-lg p-3 text-xs font-mono shadow-lg"> |
| 24 | + <div class="font-bold text-yellow-900 dark:text-yellow-100 mb-2"> |
| 25 | + AdSense Debug (Dev Only) |
| 26 | + </div> |
| 27 | + <div class="space-y-1"> |
| 28 | + {vars.map((v) => ( |
| 29 | + <div class="flex justify-between gap-2"> |
| 30 | + <span class="text-yellow-800 dark:text-yellow-200 truncate">{v.name}</span> |
| 31 | + <span class={v.value ? 'text-green-700 dark:text-green-300 font-bold' : 'text-red-700 dark:text-red-300'}> |
| 32 | + {v.value ? 'set' : 'empty'} |
| 33 | + </span> |
| 34 | + </div> |
| 35 | + ))} |
| 36 | + </div> |
| 37 | + <div class="text-yellow-700 dark:text-yellow-300 mt-2 text-[10px]"> |
| 38 | + Set vars in .env to see ad slots render. |
| 39 | + </div> |
| 40 | + </div> |
| 41 | +)} |
0 commit comments