0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Fixed accent color not updating in front-end preview

refs https://github.com/TryGhost/Ghost/pull/12717

- preview data is set on `options.data.site` so we need to read from that rather than directly from the settings cache
This commit is contained in:
Kevin Ansfield 2021-03-03 08:00:41 +00:00
parent 476d4389c6
commit 1cc3f35043
2 changed files with 23 additions and 8 deletions

View file

@ -173,8 +173,8 @@ module.exports = function ghost_head(options) { // eslint-disable-line camelcase
} }
} }
if (settingsCache.get('accent_color')) { if (options.data.site.accent_color) {
const accentColor = escapeExpression(settingsCache.get('accent_color')); const accentColor = escapeExpression(options.data.site.accent_color);
const styleTag = `<style>:root {--ghost-accent-color: ${accentColor};}</style>`; const styleTag = `<style>:root {--ghost-accent-color: ${accentColor};}</style>`;
const existingScriptIndex = _.findLastIndex(head, str => str.match(/<\/(style|script)>/)); const existingScriptIndex = _.findLastIndex(head, str => str.match(/<\/(style|script)>/));

View file

@ -1555,13 +1555,18 @@ describe('{{ghost_head}} helper', function () {
describe('accent_color', function () { describe('accent_color', function () {
it('includes style tag when set', function (done) { it('includes style tag when set', function (done) {
settingsCache.get.withArgs('accent_color').returns('#123456');
const renderObject = { const renderObject = {
post: posts[1] post: posts[1]
}; };
const templateOptions = {
site: {
accent_color: '#123456'
}
};
helpers.ghost_head(testUtils.createHbsResponse({ helpers.ghost_head(testUtils.createHbsResponse({
templateOptions,
renderObject: renderObject, renderObject: renderObject,
locals: { locals: {
relativeUrl: '/post/', relativeUrl: '/post/',
@ -1576,13 +1581,18 @@ describe('{{ghost_head}} helper', function () {
}); });
it('does not include style tag when not set', function (done) { it('does not include style tag when not set', function (done) {
settingsCache.get.withArgs('accent_color').returns(null);
const renderObject = { const renderObject = {
post: posts[1] post: posts[1]
}; };
const templateOptions = {
site: {
accent_color: null
}
};
helpers.ghost_head(testUtils.createHbsResponse({ helpers.ghost_head(testUtils.createHbsResponse({
templateOptions,
renderObject: renderObject, renderObject: renderObject,
locals: { locals: {
relativeUrl: '/post/', relativeUrl: '/post/',
@ -1597,13 +1607,18 @@ describe('{{ghost_head}} helper', function () {
}); });
it('attaches style tag to existing script/style tag', function (done) { it('attaches style tag to existing script/style tag', function (done) {
settingsCache.get.withArgs('accent_color').returns('#123456');
const renderObject = { const renderObject = {
post: posts[1] post: posts[1]
}; };
const templateOptions = {
site: {
accent_color: '#123456'
}
};
helpers.ghost_head(testUtils.createHbsResponse({ helpers.ghost_head(testUtils.createHbsResponse({
templateOptions,
renderObject: renderObject, renderObject: renderObject,
locals: { locals: {
relativeUrl: '/post/', relativeUrl: '/post/',