mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-27 12:53:13 +03:00
af4bfb8862
- purely for cleanliness! - we use kebabcase by default - tests should be kebab-case-file_spec.js (one day we want this to be .test.js)
22 lines
709 B
JavaScript
22 lines
709 B
JavaScript
const urlUtils = require('../../shared/url-utils');
|
|
const getContextObject = require('./context-object.js');
|
|
const _ = require('lodash');
|
|
|
|
function getCoverImage(data) {
|
|
const context = data.context ? data.context : null;
|
|
const contextObject = getContextObject(data, context);
|
|
|
|
if (_.includes(context, 'home') || _.includes(context, 'author')) {
|
|
if (contextObject.cover_image) {
|
|
return urlUtils.urlFor('image', {image: contextObject.cover_image}, true);
|
|
}
|
|
} else {
|
|
if (contextObject.feature_image) {
|
|
return urlUtils.urlFor('image', {image: contextObject.feature_image}, true);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
module.exports = getCoverImage;
|