dotcom-rendering
dotcom-rendering copied to clipboard
Dblatcher/apps email sign up placement 2
What does this change?
[no visible changes]
Defines a function to insert a NewsletterSignup element into an Item.body in apps rendering, if the article has a promotedNewsletter and is "Standard" (IE does not a blog, interactive page etc). The function is not called as the component to be rendered is no functional yet.
The exported insertNewsletterIntoItem function will try to insert a NewsletterSignUp according to the following rules:
- Don't put straight after bold text
- Don't put under headings
- Must have plain body text above and below
- Must be within 3 elements from the middle of the article
- Should not be next to an adSlot
- The best place is the last place meeting the criteria above.
If no suitable place is found, the article body is not modified.
How to trial
In "apps-rendering/src/server/page.tsx", import the function and add the following the render function before the call to renderBody on line 186.
item.promotedNewsletter = {
kind: 0,
value: {
identityName: 'patriarchy',
description:
'Reviewing the most important stories on feminism and sexism and those fighting for equality',
name: 'The Week in Patriarchy',
frequency: 'Weekly',
theme: 'opinion',
successDescription: 'signed up',
},
};
insertNewsletterIntoItem(item);
Why?
The new sign-up blocks are implemented on DCR and the equivalent feature is being rolled out on App-rendering.
When the NewsletterSignup is functional, the placement logic can be used to add the NewsletterSignUp BodyElement to the Item.