-
-
Save cossssmin/13acc7ee826d3fb0189e8dd277e99620 to your computer and use it in GitHub Desktop.
Adsense for Gridsome
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<ins class="adsbygoogle" | |
:data-ad-client="adClient" | |
:data-ad-slot="adSlot" | |
:data-ad-format="adFormat" | |
:style="adStyle"></ins> | |
</template> | |
<script> | |
export default { | |
props: { | |
adClient: { | |
type: String, | |
required: true | |
}, | |
adSlot: { | |
type: String, | |
required: true | |
}, | |
adFormat: { | |
type: String, | |
required: false, | |
default: 'auto' | |
}, | |
adStyle: { | |
type: String, | |
required: false, | |
default: 'display: block' | |
} | |
}, | |
mounted() { | |
(window.adsbygoogle = window.adsbygoogle || []).push({}) | |
} | |
} | |
</script> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue'; | |
// default layout | |
import DefaultLayout from '~/layouts/Default.vue'; | |
export default function (Vue, { head }) { | |
Vue.use(VueDisqus) | |
Vue.component('Layout', DefaultLayout) | |
head.script.push( | |
{ | |
type: 'text/javascript', | |
src: '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js', | |
async: true | |
} | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<Layout> | |
.... insert the following code anywhere in the layout | |
<Adsense | |
class="mb-5" | |
ad-client="ca-pub-XXXXXXXXX" | |
ad-slot="XXXXXXXXXX" | |
ad-style="display:block !important;" | |
ad-format="auto"> | |
</Adsense> | |
.... | |
</Layout> | |
</template> | |
<script> | |
import Adsense from '~/components/Adsense.vue'; | |
export default { | |
components: { | |
Adsense | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment