Skip to content

Commit

Permalink
fix: remove banner ad
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmaxed committed Oct 31, 2024
1 parent 584bc53 commit a7f5da3
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 47 deletions.
16 changes: 0 additions & 16 deletions src/_includes/assets/css/screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -2318,22 +2318,6 @@ a.banner:hover span {
}
}

.banner-ad-top {
display: none;
width: 100%;
height: auto;
padding: 10px 0px;
margin-top: calc(-1 * var(--header-height));
justify-content: center;
align-items: center;
margin-bottom: 3em;
flex-direction: column;
}

.banner-ad-top .ad-text {
display: none;
}

.banner-ad-bottom {
visibility: hidden;
padding: 10px 0px;
Expand Down
3 changes: 0 additions & 3 deletions src/_includes/layouts/post.njk
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ time #}

{% block content %}
<main id="site-main" class="post-template site-main outer">
{% if canonicalUrl | shouldCanonicalHaveGAM %}
{% include "partials/banner-ad.njk" %}
{% endif %}
<div class="inner {{ "ad-layout" if (adsEnabled) }}">
<article class="post-full post">
<header class="post-full-header">
Expand Down
5 changes: 0 additions & 5 deletions src/_includes/partials/banner-ad.njk

This file was deleted.

25 changes: 2 additions & 23 deletions src/_includes/partials/gam-lazy-loader.njk
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
document.addEventListener('DOMContentLoaded', function() {
var sidebar = document.querySelector('.sidebar');
var isSideBarDisplayed = window.getComputedStyle(sidebar).display !== 'none';
var topBannerAd = document.querySelector('.banner-ad-top');
var isScreenLarge = window.innerWidth > 900;
function prepareAdSlot(elementId) {
// Get the element by ID
const targetElement = document.getElementById(elementId);
Expand All @@ -20,7 +18,7 @@ document.addEventListener('DOMContentLoaded', function() {
if (parentElement) {
console.log(elementId)
if(elementId === 'banner-ad-top' || elementId === 'gam-ad-bottom' ) {
if (elementId === 'gam-ad-bottom' ) {
parentElement.style.backgroundColor = '#eeeef0';
if(getComputedStyle(parentElement).visibility === 'hidden') {
parentElement.style.visibility = 'inherit';
Expand All @@ -33,7 +31,7 @@ document.addEventListener('DOMContentLoaded', function() {
for (let i = 0; i < siblingElements.length; i++) {
const sibling = siblingElements[i];
// Skip the banner-ad-top element itself
// Skip the element itself
if (sibling === targetElement) continue;
// Log the sibling or perform any other action
Expand Down Expand Up @@ -90,25 +88,6 @@ document.addEventListener('DOMContentLoaded', function() {
}
}
if(isScreenLarge){
// Show the container
topBannerAd.style.display = 'flex';
// Define the ad slot with size mapping
googletag.cmd.push(function() {
var mapping = googletag.sizeMapping()
.addSize([1024, 768], [[970, 90], [728, 90]]) // Large screens: 970x90 or 728x90
.addSize([768, 0], [[468, 60]]) // Medium screens: 468x60
.addSize([0, 0], [[320, 50]]) // Small screens: 320x50
.build();
// Define the ad slot
googletag.defineSlot('/23075930536/post-top', [[970, 90], [728, 90], [468, 60], [320, 50]], 'banner-ad-top')
.defineSizeMapping(mapping) // Apply size mapping to this slot
.addService(googletag.pubads());
});
}
// Define bottom ad
googletag.defineSlot('/23075930536/post-bottom', ['fluid'], 'gam-ad-bottom').addService(googletag.pubads());
Expand Down

0 comments on commit a7f5da3

Please sign in to comment.