Updated ghost_head & ghost_foot to work with tags

no-issue

This adds support for tags codeinjection to work with the ghost_head and
ghost_foot helpers
This commit is contained in:
Fabien O'Carroll 2020-07-10 14:20:22 +02:00
parent 2dd302a23e
commit 1d8154f892
2 changed files with 10 additions and 0 deletions

View File

@ -11,6 +11,7 @@ module.exports = function ghost_foot(options) { // eslint-disable-line camelcase
const globalCodeinjection = settingsCache.get('codeinjection_foot');
const postCodeinjection = options.data.root && options.data.root.post ? options.data.root.post.codeinjection_foot : null;
const tagCodeinjection = options.data.root && options.data.root.tag ? options.data.root.tag.codeinjection_foot : null;
if (!_.isEmpty(globalCodeinjection)) {
foot.push(globalCodeinjection);
@ -20,5 +21,9 @@ module.exports = function ghost_foot(options) { // eslint-disable-line camelcase
foot.push(postCodeinjection);
}
if (!_.isEmpty(tagCodeinjection)) {
foot.push(tagCodeinjection);
}
return new SafeString(foot.join(' ').trim());
};

View File

@ -99,6 +99,7 @@ module.exports = function ghost_head(options) { // eslint-disable-line camelcase
const context = dataRoot._locals.context ? dataRoot._locals.context : null;
const safeVersion = dataRoot._locals.safeVersion;
const postCodeInjection = dataRoot && dataRoot.post ? dataRoot.post.codeinjection_head : null;
const tagCodeInjection = dataRoot && dataRoot.tag ? dataRoot.tag.codeinjection_head : null;
const globalCodeinjection = settingsCache.get('codeinjection_head');
const useStructuredData = !config.isPrivacyDisabled('useStructuredData');
const referrerPolicy = config.get('referrerPolicy') ? config.get('referrerPolicy') : 'no-referrer-when-downgrade';
@ -189,6 +190,10 @@ module.exports = function ghost_head(options) { // eslint-disable-line camelcase
if (!_.isEmpty(postCodeInjection)) {
head.push(postCodeInjection);
}
if (!_.isEmpty(tagCodeInjection)) {
head.push(tagCodeInjection);
}
}
debug('end');
return new SafeString(head.join('\n ').trim());