|
|
@ -3,16 +3,16 @@ import { ref, watch, onMounted } from 'vue'
|
|
|
|
import { useData } from 'vitepress'
|
|
|
|
import { useData } from 'vitepress'
|
|
|
|
import { useAside } from '../composables/aside.js'
|
|
|
|
import { useAside } from '../composables/aside.js'
|
|
|
|
|
|
|
|
|
|
|
|
const { theme } = useData()
|
|
|
|
const { theme, page } = useData()
|
|
|
|
const carbonOptions = theme.value.carbonAds
|
|
|
|
const carbonOptions = theme.value.carbonAds
|
|
|
|
const { isAsideEnabled } = useAside()
|
|
|
|
const { isAsideEnabled } = useAside()
|
|
|
|
const container = ref()
|
|
|
|
const container = ref()
|
|
|
|
|
|
|
|
|
|
|
|
let hasInitalized = false
|
|
|
|
let isInitialized = false
|
|
|
|
|
|
|
|
|
|
|
|
function init() {
|
|
|
|
function init() {
|
|
|
|
if (!hasInitalized) {
|
|
|
|
if (!isInitialized) {
|
|
|
|
hasInitalized = true
|
|
|
|
isInitialized = true
|
|
|
|
const s = document.createElement('script')
|
|
|
|
const s = document.createElement('script')
|
|
|
|
s.id = '_carbonads_js'
|
|
|
|
s.id = '_carbonads_js'
|
|
|
|
s.src = `//cdn.carbonads.com/carbon.js?serve=${carbonOptions.code}&placement=${carbonOptions.placement}`
|
|
|
|
s.src = `//cdn.carbonads.com/carbon.js?serve=${carbonOptions.code}&placement=${carbonOptions.placement}`
|
|
|
@ -21,6 +21,12 @@ function init() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
watch(() => page.value.relativePath, () => {
|
|
|
|
|
|
|
|
if (isInitialized && isAsideEnabled.value) {
|
|
|
|
|
|
|
|
;(window as any)._carbonads?.refresh()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// no need to account for option changes during dev, we can just
|
|
|
|
// no need to account for option changes during dev, we can just
|
|
|
|
// refresh the page
|
|
|
|
// refresh the page
|
|
|
|
if (carbonOptions) {
|
|
|
|
if (carbonOptions) {
|
|
|
|