Coder Social home page Coder Social logo

vuepress-plugin-google-adsense's Introduction

vuepress-plugin-google-adsense

Google adsense plugin for vuepress

Use google automatic advertisement for your vuepress site. (Follow Google Ad Code Implementation Guide)

npm download GitHub license

Install

yarn add -D vuepress-plugin-google-adsense
# OR
# npm install -D vuepress-plugin-google-adsense

Usage

module.exports = {
  plugins: [
    [
      "vuepress-plugin-google-adsense",
      {
        adClient: "ca-pub-2245427233262012", // replace it with your adClient
      },
    ],
  ],
};

More Info: Using a Plugin

If you don't have a google adsense account, you need register one here.

If you pass, google adsense will give you a script like this.

<script
  data-ad-client="ca-pub-2245427233262012"
  async
  src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"
></script>

Other method

In fact, when this plugin was developed, Google's automatic adsense code was not as simple as it is now.

And now, you can just insert the following code in config.js instead of this plugin.

module.exports = {
  head: [
    [
      "script",
      {
        "data-ad-client": "ca-pub-2245427233262012",
        async: true,
        src: "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js",
      },
    ],
  ],
};

Config Reference | Vupress

One advantage of plugin is that it can decide whether to show by ctx.isProd.

Options

Name Type Required Default Description
adClient string true undefined Provide the Google Adsense ID to enable integration.
adsTxt boolean false false Whether to generate ads.txt

adsTxt

If you enable it, the following content will be generated in ads.txt.

ads.txt Guide | Google AdSense

google.com, pub-2245427233262012, DIRECT, f08c47fec0942fa0

vuepress-plugin-google-adsense's People

Contributors

62che avatar yunyoujun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

62che

vuepress-plugin-google-adsense's Issues

Support ads.txt

Hello @YunYouJun ,

is it possible to support the ads.txt Google requires? Not sure if and how you would do this.

Cheers,
Peter

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.