diff --git a/core/frontend/services/theme-engine/middleware/update-global-template-options.js b/core/frontend/services/theme-engine/middleware/update-global-template-options.js index e28c063542..9324fc175b 100644 --- a/core/frontend/services/theme-engine/middleware/update-global-template-options.js +++ b/core/frontend/services/theme-engine/middleware/update-global-template-options.js @@ -36,7 +36,11 @@ async function updateGlobalTemplateOptions(req, res, next) { { hbs.updateTemplateOptions({ data: { - site: siteData, + site: { + ...siteData, + comments_enabled: siteData.comments_enabled !== 'off', + comments_access: siteData.comments_enabled + }, labs: labsData, config: themeData, custom: themeSettingsData diff --git a/core/shared/settings-cache/public.js b/core/shared/settings-cache/public.js index e3f169de48..a0aaa869bf 100644 --- a/core/shared/settings-cache/public.js +++ b/core/shared/settings-cache/public.js @@ -36,5 +36,6 @@ module.exports = { portal_button_icon: 'portal_button_icon', portal_plans: 'portal_plans', portal_name: 'portal_name', - portal_button: 'portal_button' + portal_button: 'portal_button', + comments_enabled: 'comments_enabled' }; diff --git a/test/e2e-api/content/__snapshots__/settings.test.js.snap b/test/e2e-api/content/__snapshots__/settings.test.js.snap index 0f1c0703e4..ab7e70cb15 100644 --- a/test/e2e-api/content/__snapshots__/settings.test.js.snap +++ b/test/e2e-api/content/__snapshots__/settings.test.js.snap @@ -7,6 +7,7 @@ Object { "accent_color": "#FF1A75", "codeinjection_foot": null, "codeinjection_head": null, + "comments_enabled": null, "cover_image": "https://static.ghost.org/v4.0.0/images/publication-cover.jpg", "description": "Thoughts, stories and ideas", "facebook": "ghost", diff --git a/test/e2e-api/shared/__snapshots__/version.test.js.snap b/test/e2e-api/shared/__snapshots__/version.test.js.snap index 4607d4eb95..f9b91d5872 100644 --- a/test/e2e-api/shared/__snapshots__/version.test.js.snap +++ b/test/e2e-api/shared/__snapshots__/version.test.js.snap @@ -485,6 +485,7 @@ Object { "accent_color": "#FF1A75", "codeinjection_foot": null, "codeinjection_head": null, + "comments_enabled": null, "cover_image": "https://static.ghost.org/v4.0.0/images/publication-cover.jpg", "description": "Thoughts, stories and ideas", "facebook": "ghost", @@ -578,6 +579,7 @@ Object { "accent_color": "#FF1A75", "codeinjection_foot": null, "codeinjection_head": null, + "comments_enabled": null, "cover_image": "https://static.ghost.org/v4.0.0/images/publication-cover.jpg", "description": "Thoughts, stories and ideas", "facebook": "ghost", diff --git a/test/unit/frontend/services/theme-engine/middleware.test.js b/test/unit/frontend/services/theme-engine/middleware.test.js index c547d77ae3..8ad30304c3 100644 --- a/test/unit/frontend/services/theme-engine/middleware.test.js +++ b/test/unit/frontend/services/theme-engine/middleware.test.js @@ -49,7 +49,9 @@ describe('Themes middleware', function () { fakeActiveThemeName = 'bacon-sensation'; - fakeSiteData = {}; + fakeSiteData = { + comments_enabled: 'all' + }; fakeLabsData = { // labs data is deep cloned, @@ -159,9 +161,16 @@ describe('Themes middleware', function () { // Check labs config should.deepEqual(data.labs, fakeLabsData); - should.equal(data.site, fakeSiteData); - should.exist(data.site.signup_url); - data.site.signup_url.should.equal('#/portal'); + should.deepEqual(data.site, { + ...fakeSiteData, + + // signup_url should get added + signup_url: '#/portal', + + // the comments_enabled setting should be mapped to comments_access, and comments_enabled should be a boolean + comments_enabled: true, + comments_access: 'all' + }); should.deepEqual(data.custom, fakeCustomThemeSettingsData);