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

[feature request] Google Adsense Integration for VuePress... #7

Closed m3andros closed 5 years ago

m3andros commented 6 years ago

Is there a way to implement Adsense for VuePress, please?

mazipan commented 6 years ago

From this link https://vuepress.vuejs.org/guide/basic-config.html#app-level-enhancements You can create file .vuepress/enhanceApp.js with code like this:

export default ({
  Vue, // the version of Vue being used in the VuePress app
  options, // the options for the root Vue instance
  router, // the router instance for the app
  siteData // site metadata
}) => {
  // ...apply enhancements to the app
  // ...install additional plugin here
}
m3andros commented 6 years ago

Thanks for the assistance @mazipan. I've gotten it to work, except I am now getting this error: Failed to load resource: the server responded with a status of 400 ()

Not sure what the error means, since the Adsense ad isn't loading. Only a hollow white space is displaying. I've added the following to "test" the ad: data-adtest="on" - but no cigar.

Any help you can provide would be most helpful!

Thank you.

mazipan commented 6 years ago

Hmmm, white space is not always because this plugin not working. Sometimes it because your Adsense not work properly.

Just inspect element and make sure you can found this kind of element:

<ins data-ad-client="ca-pub-XXXXXXX" data-ad-slot="XXXXXX" data-ad-test="" data-ad-format="auto" class="adsbygoogle" data-adsbygoogle-status="done" style="display: block; height: 90px;">
....any child here
</ins>
screen shot 2018-09-05 at 14 39 18
marslord commented 5 years ago

I didn't get error info, only render <Adsense data-ad-client="ca-pub-xxx" data-ad-slot="xxx123"></Adsense> in the page. My enhanceApp.js below:

export default ({
    Vue, // the version of Vue being used in the VuePress app
    options, // the options for the root Vue instance
    router, // the router instance for the app
    siteData // site metadata
}) => {
    // ...apply enhancements to the app
    Vue.use(require('vue-script2'))

    Vue.use(require('vue-google-adsense/dist/Adsense.min.js'))

    // Vue.use(require('vue-google-adsense/dist/InArticleAdsense.min.js'))

    // Vue.use(require('vue-google-adsense/dist/InFeedAdsense.min.js'))
}

@m3andros Hi man. Could you share a demo code for showing how it works? Thank you in advance!