Insert partial or data driven content X words or characters into .Content

We’re building a banner ad system by using data driven content (json). We would like to insert one type of banner ad inside of {{ .Content }} on blog posts.

A natural way would be to put part of the content in frontmatter and display that before {{ .Content}}, but that entails the writer remembering to manually split the content. Another option is @digitalcraftsman solution, but this also puts additional requirements on the writer.

A slicker way would be if a partial could be inserted X words or characters into {{ .Content }}. We’ve looked into slicestr but not sure how to use it in this particular case.

Ideally we would want it to look like this:

  1. Content (first 150 words)
  2. Banner ad
  3. Content (continued)