We are rendering structured text on our react frontend. We need to push DFP ads within the body content. One ad after first two paragraphs, second ad after first 6 paragraphs and so on. Is it possible to push DFP ads while we are rendering with StructuredText?
We tried -
customRules={[
renderRule(
isParagraph,
({ adapter: { renderNode }, node, children, key, ancestors }) => {
if (isRoot(ancestors[0])) {
return renderNode('p', { key, className: 'top-level-p-tag' }, children);
} else {
return renderNode('p', { key }, children);
}
}
)
]}
But issue is that there are other top level elements too like blockqoute, div etc and also we have custom renderBlock for videos, codeblock etc.