mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 19:52:01 +03:00
21 lines
577 B
JavaScript
21 lines
577 B
JavaScript
|
var config = require('../../config');
|
||
|
|
||
|
function getCoverImage(data) {
|
||
|
var context = data.context ? data.context[0] : null,
|
||
|
blog = config.theme,
|
||
|
contextObject = data[context] || blog;
|
||
|
|
||
|
if (context === 'home' || context === 'author') {
|
||
|
if (contextObject.cover) {
|
||
|
return config.urlFor('image', {image: contextObject.cover}, true);
|
||
|
}
|
||
|
} else {
|
||
|
if (contextObject.image) {
|
||
|
return config.urlFor('image', {image: contextObject.image}, true);
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
module.exports = getCoverImage;
|