|
|
@@ -6,6 +6,7 @@ import { useData } from 'vitepress/dist/client/theme-default/composables/data'
|
|
|
const { page } = useData()
|
|
|
const props = defineProps<{
|
|
|
carbonAds: DefaultTheme.CarbonAdsOptions
|
|
|
+ variant?: 'sidebar' | 'mobile-bottom'
|
|
|
}>()
|
|
|
|
|
|
const carbonOptions = props.carbonAds
|
|
|
@@ -35,7 +36,22 @@ watch(() => page.value.relativePath, () => {
|
|
|
// refresh the page
|
|
|
if (carbonOptions) {
|
|
|
onMounted(() => {
|
|
|
- init()
|
|
|
+ // Explicitly check variant to prevent ID conflicts
|
|
|
+ const isMobile = window.matchMedia('(max-width: 1280px)').matches
|
|
|
+
|
|
|
+ if (props.variant === 'sidebar' && isMobile) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (props.variant === 'mobile-bottom' && !isMobile) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // Only initialize if the container is visible to avoid ID conflicts
|
|
|
+ // with other instances (e.g. sidebar vs bottom)
|
|
|
+ if (container.value && container.value.offsetParent !== null) {
|
|
|
+ init()
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
</script>
|