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:
- Content (first 150 words)
- Banner ad
- Content (continued)