Skip to content

Instantly share code, notes, and snippets.

@rabehasy
Last active August 5, 2019 21:12
Show Gist options
  • Save rabehasy/8e9c4c36d2865dcae41224f719612cc6 to your computer and use it in GitHub Desktop.
Save rabehasy/8e9c4c36d2865dcae41224f719612cc6 to your computer and use it in GitHub Desktop.
hexo.extend.tag.register('googleads', function(args) {
if (args.length !== 3) {
return '';
}
let layout = args[0]; // ex: in-article
let format = args[1]; // ex: fluid
let slot = args[2];
let sHtml = '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>' + "\n";
sHtml += '<ins class="adsbygoogle"' + "\n";
sHtml += 'style="display:block; text-align:center;"' + "\n";
sHtml += 'data-ad-layout="' + layout + '"' + "\n";
sHtml += 'data-ad-format="' + format + '"' + "\n";
sHtml += 'data-ad-client="ca-pub-***********"' + "\n";
sHtml += 'data-ad-slot="' + slot + '"' + "\n";
sHtml += '></ins>' + "\n";
sHtml += '<script>' + "\n";
sHtml += '(adsbygoogle = window.adsbygoogle || []).push({});' + "\n";
sHtml += '</script>' + "\n";
return sHtml;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment