vuepress-plugin-google-adsense

0.2.1 • Public • Published

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

Package Sidebar

Install

npm i vuepress-plugin-google-adsense

Weekly Downloads

8

Version

0.2.1

License

MIT

Unpacked Size

6.11 kB

Total Files

5

Last publish

Collaborators

  • yunyoujun