mazipan / vue-google-adsense

💰 Vue.js Google Adsense Component with InFeed and InArticle Ads support
https://mazipan.github.io/vue-google-adsense/
MIT License
257 stars 42 forks source link

How do I integrate this with NuxtJS? #1

Closed rlam3 closed 6 years ago

rlam3 commented 6 years ago

How do I integrate this with NuxtJS?

mazipan commented 6 years ago

Honestly, I never test for Nuxt and also didn't understand how plugin work in Nuxt. Maybe need some research for me. I will keep this issue open and will poke you if already supported.

Thanks @rlam3 👍

AlexLomm commented 6 years ago

I would also love support for Nuxt

mazipan commented 6 years ago

Is there any link or sample project to create Plugin in Nuxt @AlexLomm ?

AlexLomm commented 6 years ago

I hope this can help: https://nuxtjs.org/guide/plugins#__nuxt

mazipan commented 6 years ago

After reading that tutorial, I think we don't need to change any code here. Just need clarify how to use this plugin.

From the article we can do like this, but still need tested :

Create file plugins/vue-google-adsense.js, with code :

import Vue from 'vue'
import Ads from 'vue-google-adsense'

Vue.use(require('vue-script2'))

Vue.use(Ads.Adsense)
Vue.use(Ads.InArticleAdsense)
Vue.use(Ads.InFeedAdsense)

Then update your nuxt.config.js, with code :

module.exports = {
  plugins: [
    { src: '~/plugins/vue-google-adsense', ssr: false }
  ]
}

Hope this help you @AlexLomm @rlam3

AlexLomm commented 6 years ago

Thank you a lot for taking your time and investigating the issue!

It seems to be working now, thank you a lot. I'll report back if I encounter any problems.

P.S I tried this exact approach without the ssr: false option, my bad.

mazipan commented 6 years ago

Okay @AlexLomm, I will put this issue to main docs in README.md. So, people that have same problem can be solved with same approach.

Dont forget to give star ⭐️ in this repo ya. Very appreciate that thing.