remark-auto-ads
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

remark-auto-ads

remark.js plugin that automatically inserts Google Adsense (and theoretically any ad service) code.

This plugin inserts an ad code for each specified number of paragraphs. For example, insert Google Adsense display ad code every 5 paragraphs.

(Unlike Google Adsense's automatic ads) no ad code is inserted into blockquote or list items!

Install

npm install remark-auto-ads

Usage

import remark from "remark";
import remarkAutoAds from "remark-auto-ads";

const processor = remark().use(remarkAutoAds, {
    adCode: "<AD_CODE>",
    paragraphInterval: 2
});

const markdown = `
# Hello, world!

This is a paragraph.

This is a paragraph.

This is a paragraph.

This is a paragraph.
`;

processor.process(markdown).then((result) => {
    console.log(result.toString());
});

The above code will output the following:

# Hello, world!

This is a paragraph.

This is a paragraph.

<AD_CODE>

This is a paragraph.

This is a paragraph.

<AD_CODE>

Options

export interface RemarkAutoAdsOptions {
    adCode: string;
    countFrom?: number;
    paragraphInterval?: number;
}

adCode

The ad code to be inserted. For example, Google Adsense display ad code.

countFrom

Initial value of paragraph counter. In other words, this value should be set to the value of paragraphInterval minus the number of paragraphs you want to insert the first ad.

If you want to insert ad code from the third paragraph and every 5 paragraphs, set this to 2.

Default: 0

paragraphInterval

The value indicating how many paragraphs to insert advertising code. For example, specifying 5 will insert ads every 5 paragraphs.

Default: 5

Readme

Keywords

Package Sidebar

Install

npm i remark-auto-ads

Weekly Downloads

2

Version

1.0.2

License

MIT

Unpacked Size

7.29 kB

Total Files

5

Last publish

Collaborators

  • robot-inventor