Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/components/ad/AdBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<!-- Ad container with required attributes -->
<div ref="containerRef" class="flex w-full justify-center overflow-hidden" :style="containerStyle">
<ins
ref="insRef"
class="adsbyslise"
:style="adStyle"
:data-ad-slot="slot"
Expand All @@ -12,7 +13,8 @@
</template>

<script setup lang="ts">
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { useRoute } from 'vue-router';

declare global {
interface Window {
Expand Down Expand Up @@ -47,7 +49,9 @@ const props = defineProps({
});

const containerRef = ref<HTMLElement | null>(null);
const insRef = ref<HTMLElement | null>(null);
const scale = ref(1);
const route = useRoute();

function toPixels(value: string) {
const parsed = Number.parseFloat(value);
Expand Down Expand Up @@ -102,6 +106,12 @@ onMounted(() => {
}
});

watch(() => route.fullPath, () => {
if (!insRef.value || typeof window.adsbyslisesync !== 'function') return;
insRef.value.removeAttribute('data-ad-loaded');
window.adsbyslisesync();
});

onBeforeUnmount(() => {
observer?.disconnect();
});
Expand Down
6 changes: 2 additions & 4 deletions src/layouts/components/DefaultLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,10 @@ const show_ad = computed(() => {
>
</div>
</div>
<AdBanner v-if="show_ad" />
<RouterView v-slot="{ Component }">
<Transition mode="out-in">
<div>
<AdBanner v-if="show_ad" />
<Component :is="Component" />
</div>
<Component :is="Component" />
</Transition>
</RouterView>
</div>
Expand Down
Loading