mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 10:21:36 +03:00
d9fef82170
#10921 - Changed {{meta_title}} helper to use site meta_title' field - Changed {{meta_description}} helper to use site 'meta_description' field - Changed {{og_image}} helper to use site 'og_image' field - Added site title handling for og/twitter metadata - Refactored use of 'blog' in variable name in favor of 'site' - Extended meta_description test suite with 'home' context cases - Changed {{twitter_image}} helper to use site 'twitter_image' field - Added ghost_head test for site metadata - Renamed blog->site in variable names for touched files
27 lines
1010 B
JavaScript
27 lines
1010 B
JavaScript
const _ = require('lodash');
|
|
const urlUtils = require('../../server/lib/url-utils');
|
|
const getContextObject = require('./context_object.js');
|
|
const settingsCache = require('../../server/services/settings/cache');
|
|
|
|
function getTwitterImage(data) {
|
|
const context = data.context ? data.context : null;
|
|
const contextObject = getContextObject(data, context);
|
|
const siteTwitterImage = settingsCache.get('twitter_image');
|
|
|
|
if (_.includes(context, 'post') || _.includes(context, 'page') || _.includes(context, 'amp')) {
|
|
if (contextObject.twitter_image) {
|
|
return urlUtils.urlFor('image', {image: contextObject.twitter_image}, true);
|
|
} else if (contextObject.feature_image) {
|
|
return urlUtils.urlFor('image', {image: contextObject.feature_image}, true);
|
|
}
|
|
}
|
|
|
|
if (_.includes(context, 'home') && siteTwitterImage) {
|
|
return urlUtils.urlFor('image', {image: siteTwitterImage}, true);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
module.exports = getTwitterImage;
|