From 1d8154f8927515883d41277bf31be0e371a33ada Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Fri, 10 Jul 2020 14:20:22 +0200 Subject: [PATCH] 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 --- core/frontend/helpers/ghost_foot.js | 5 +++++ core/frontend/helpers/ghost_head.js | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/core/frontend/helpers/ghost_foot.js b/core/frontend/helpers/ghost_foot.js index 37d4faf4cb..25aa4a7e6a 100644 --- a/core/frontend/helpers/ghost_foot.js +++ b/core/frontend/helpers/ghost_foot.js @@ -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()); }; diff --git a/core/frontend/helpers/ghost_head.js b/core/frontend/helpers/ghost_head.js index bbd542d34d..9d12021833 100644 --- a/core/frontend/helpers/ghost_head.js +++ b/core/frontend/helpers/ghost_head.js @@ -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());