Added comment CTA in newsletters

fixes https://github.com/TryGhost/Team/issues/2672

- Moves the feature from behind the flag
- Also hides the comment CTA for email only posts

Co-authored-by: Sanne de Vries <sannedv@protonmail.com>
This commit is contained in:
Simon Backx 2023-03-17 09:01:35 +01:00 committed by Simon Backx
parent 86446e4c86
commit 25f4974846
3 changed files with 6 additions and 4 deletions

View File

@ -73,7 +73,7 @@ module.exports = async function comments(options) {
const dataAttributes = getDataAttributes(data);
return new SafeString(`
<script defer src="${scriptUrl}" ${dataAttributes} crossorigin="anonymous"></script>
<div id="ghost-comments-test"></div><script defer src="${scriptUrl}" ${dataAttributes} crossorigin="anonymous"></script>
`);
};

View File

@ -590,6 +590,8 @@ class EmailRenderer {
const commentUrl = new URL(postUrl);
commentUrl.hash = '#ghost-comments-root';
const hasEmailOnlyFlag = post.related('posts_meta')?.get('email_only') ?? false;
const data = {
site: {
title: this.#settingsCache.get('title'),
@ -617,7 +619,7 @@ class EmailRenderer {
newsletter: {
name: newsletter.get('name'),
showPostTitleSection: newsletter.get('show_post_title_section'),
showCommentCta: newsletter.get('show_comment_cta') && this.#settingsCache.get('comments_enabled') !== 'off' && this.#labs.isSet('makingItRain'),
showCommentCta: newsletter.get('show_comment_cta') && this.#settingsCache.get('comments_enabled') !== 'off' && !hasEmailOnlyFlag,
showSubscriptionDetails: newsletter.get('show_subscription_details') && this.#labs.isSet('makingItRain')
},

View File

@ -1089,7 +1089,7 @@ describe('Email renderer', function () {
});
});
it('show comment CTA is disabled if labs disabled', async function () {
it('show comment CTA is enabled if labs disabled', async function () {
labsEnabled = false;
settings.comments_enabled = 'all';
const html = '';
@ -1105,7 +1105,7 @@ describe('Email renderer', function () {
show_comment_cta: true
});
const data = await emailRenderer.getTemplateData({post, newsletter, html, addPaywall: false});
assert.equal(data.newsletter.showCommentCta, false);
assert.equal(data.newsletter.showCommentCta, true);
});
it('show comment CTA is disabled if comments disabled', async function () {