Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1013 from parameter1/newsletter-teaser-p
Browse files Browse the repository at this point in the history
Add wrapping <p> tags to newsletter content teasers
  • Loading branch information
brandonbk authored Nov 15, 2024
2 parents 32d68b2 + 7f2e2a0 commit b4e29c0
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ module.exports = async (apolloClient, {

const { data } = await apolloClient.query({ query, variables });
if (!data || !data.newsletterScheduledContent) return { nodes: [] };
const nodes = data.newsletterScheduledContent;
const regex = /^\s+<p/;
const nodes = data.newsletterScheduledContent.map((node) => ({
...node,
...(node.teaser && !regex.test(node.teaser) && {
teaser: `<p>${node.teaser}</p>`,
}),
}));

return { nodes };
};

0 comments on commit b4e29c0

Please sign in to comment.