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:
parent
476d4389c6
commit
1cc3f35043
2 changed files with 23 additions and 8 deletions
|
@ -173,8 +173,8 @@ module.exports = function ghost_head(options) { // eslint-disable-line camelcase
|
|||
}
|
||||
}
|
||||
|
||||
if (settingsCache.get('accent_color')) {
|
||||
const accentColor = escapeExpression(settingsCache.get('accent_color'));
|
||||
if (options.data.site.accent_color) {
|
||||
const accentColor = escapeExpression(options.data.site.accent_color);
|
||||
const styleTag = `<style>:root {--ghost-accent-color: ${accentColor};}</style>`;
|
||||
const existingScriptIndex = _.findLastIndex(head, str => str.match(/<\/(style|script)>/));
|
||||
|
||||
|
|
|
@ -1555,13 +1555,18 @@ describe('{{ghost_head}} helper', function () {
|
|||
|
||||
describe('accent_color', function () {
|
||||
it('includes style tag when set', function (done) {
|
||||
settingsCache.get.withArgs('accent_color').returns('#123456');
|
||||
|
||||
const renderObject = {
|
||||
post: posts[1]
|
||||
};
|
||||
|
||||
const templateOptions = {
|
||||
site: {
|
||||
accent_color: '#123456'
|
||||
}
|
||||
};
|
||||
|
||||
helpers.ghost_head(testUtils.createHbsResponse({
|
||||
templateOptions,
|
||||
renderObject: renderObject,
|
||||
locals: {
|
||||
relativeUrl: '/post/',
|
||||
|
@ -1576,13 +1581,18 @@ describe('{{ghost_head}} helper', function () {
|
|||
});
|
||||
|
||||
it('does not include style tag when not set', function (done) {
|
||||
settingsCache.get.withArgs('accent_color').returns(null);
|
||||
|
||||
const renderObject = {
|
||||
post: posts[1]
|
||||
};
|
||||
|
||||
const templateOptions = {
|
||||
site: {
|
||||
accent_color: null
|
||||
}
|
||||
};
|
||||
|
||||
helpers.ghost_head(testUtils.createHbsResponse({
|
||||
templateOptions,
|
||||
renderObject: renderObject,
|
||||
locals: {
|
||||
relativeUrl: '/post/',
|
||||
|
@ -1597,13 +1607,18 @@ describe('{{ghost_head}} helper', function () {
|
|||
});
|
||||
|
||||
it('attaches style tag to existing script/style tag', function (done) {
|
||||
settingsCache.get.withArgs('accent_color').returns('#123456');
|
||||
|
||||
const renderObject = {
|
||||
post: posts[1]
|
||||
};
|
||||
|
||||
const templateOptions = {
|
||||
site: {
|
||||
accent_color: '#123456'
|
||||
}
|
||||
};
|
||||
|
||||
helpers.ghost_head(testUtils.createHbsResponse({
|
||||
templateOptions,
|
||||
renderObject: renderObject,
|
||||
locals: {
|
||||
relativeUrl: '/post/',
|
||||
|
|
Loading…
Reference in a new issue