mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 03:44:29 +03:00
✨ 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:
parent
86446e4c86
commit
25f4974846
@ -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>
|
||||
`);
|
||||
};
|
||||
|
||||
|
@ -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')
|
||||
},
|
||||
|
||||
|
@ -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 () {
|
||||
|
Loading…
Reference in New Issue
Block a user