mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 06:35:49 +03:00
Added data-comments-enabled
attribute to comments helper
refs https://github.com/TryGhost/Team/issues/1693 - The comments section needs to know the access settings for comments - Updated the comments helper to also double check access settings (comments enabled + member has access to the post)
This commit is contained in:
parent
b671504a2c
commit
0c5c1abb1a
@ -1,5 +1,5 @@
|
||||
const {SafeString} = require('../services/handlebars');
|
||||
const {config, urlUtils, getFrontendKey, labs} = require('../services/proxy');
|
||||
const {config, urlUtils, getFrontendKey, labs, settingsCache} = require('../services/proxy');
|
||||
|
||||
async function comments(options) {
|
||||
// todo: For now check on the comment id to exclude normal pages (we probably have a better way to do this)
|
||||
@ -9,6 +9,18 @@ async function comments(options) {
|
||||
if (!commentId) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* We need to check if comments enabled, because the theme might not be using the other available helpers to check
|
||||
* if comments is enabled + the member has access
|
||||
* @type {'all'|'paid'|'off'}
|
||||
*/
|
||||
const commentsEnabled = settingsCache.get('comments_enabled');
|
||||
const hasAccess = !!this.access;
|
||||
|
||||
if (commentsEnabled === 'off' || !hasAccess) {
|
||||
return;
|
||||
}
|
||||
|
||||
let colorScheme = 'auto';
|
||||
if (options.hash.color_scheme === 'dark' || options.hash.color_scheme === 'light') {
|
||||
@ -37,7 +49,8 @@ async function comments(options) {
|
||||
'color-scheme': colorScheme,
|
||||
'avatar-saturation': avatarSaturation,
|
||||
'accent-color': accentColor,
|
||||
'app-version': config.get('comments:version')
|
||||
'app-version': config.get('comments:version'),
|
||||
'comments-enabled': commentsEnabled
|
||||
};
|
||||
|
||||
let dataAttributes = '';
|
||||
|
Loading…
Reference in New Issue
Block a user