Ghost/core/server/data/meta/context_object.js
Hannah Wolfe 63723aa36a 🎨 Move settings cache & cleanup settings API (#8057)
closes #8037

🔥 Remove API-level default settings population
- This is a relic!
- We ALWAYS populate defaults on server start therefore this code could never run.
- This was a lot of complicated code that wasn't even needed!!

🎨 Move settings cache
- Move settings cache to be its own thing
- Update all references
- Adds TODOs for further cleanup

🎨 Create settings initialisation step
- Create new settings library, which will eventually house more code
- Unify the interface for initialising settings (will be more useful later)
- Reduce number of calls to updateSettingsCache
2017-02-27 16:53:04 +01:00

21 lines
638 B
JavaScript

var settingsCache = require('../../settings/cache'),
_ = require('lodash');
function getContextObject(data, context) {
/**
* If the data object does not contain the requested context, we return the fallback object.
*/
var blog = {
cover: settingsCache.get('cover'),
twitter: settingsCache.get('twitter'),
facebook: settingsCache.get('facebook')
},
contextObject;
context = _.includes(context, 'page') || _.includes(context, 'amp') ? 'post' : context;
contextObject = data[context] || blog;
return contextObject;
}
module.exports = getContextObject;