Ghost/core/server/data/meta/context_object.js
Katharina Irrgang 76bd4fdef6 🙀 Image field naming & new img_url helper (#8364)
* 🙀  change database schema for images
    - rename user/post/tag images
    - contains all the required changes from the schema change

* Refactor helper/meta data
    - rename cover to cover_image
    - also rename default settings to match the pattern
    - rename image to profile_image for user
    - rename image to feature_image for tags/posts

* {{image}} >>> {{img_url}}
    - rename
    - change the functionality
    - attr is required
    - e.g. {{img_url feature_image}}

* gscan 1.0.0
    - update yarn.lock

* Update casper reference: 1.0-changes
    - see 5487b4da8d
2017-04-24 18:21:47 +01:00

21 lines
650 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_image: settingsCache.get('cover_image'),
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;