Inject <amp-ad> inside .Content - query

I have an output type for AMP and would like to insert <amp-ad> inside .Content.

Any direction which i can follow?

Do you want to insert the ad while creating/editing the content, or do you want Hugo to insert the ad when building the site?

I want ad to be inserted by hugo during build process as per code/configuration.

For example:

  1. I should be able to insert amp ad after every 2 paragraphs (configurable). May be first ad after 2nd paragraph then second ad after after 3rd paragraph etc.

  2. Or i should be able to insert ad based on word count.

You will have to manipulate .Content in your templates using findRE, replaceRE, etc.