Ghost/core/server/data/meta/cover_image.js
cobbspur 5102637b8e Add structured data to static pages
refs #6534

- adds structured data on static pages
- selects post context object for static pages
- updates tests
2016-03-30 12:57:13 +01:00

21 lines
623 B
JavaScript

var config = require('../../config'),
getContextObject = require('./context_object.js');
function getCoverImage(data) {
var context = data.context ? data.context[0] : null,
contextObject = getContextObject(data, context);
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;