mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-16 12:16:09 +03:00
44537bd15f
closes #6911 - update lodash to v4 - remove lodash.tostring override - remove lodash from greenkeeper ignore
26 lines
910 B
JavaScript
26 lines
910 B
JavaScript
var _ = require('lodash'),
|
|
config = require('../../config');
|
|
|
|
function getDescription(data, root) {
|
|
var description = '',
|
|
context = root ? root.context : null;
|
|
|
|
if (data.meta_description) {
|
|
description = data.meta_description;
|
|
} else if (_.includes(context, 'paged')) {
|
|
description = '';
|
|
} else if (_.includes(context, 'home')) {
|
|
description = config.theme.description;
|
|
} else if (_.includes(context, 'author') && data.author) {
|
|
description = data.author.meta_description || data.author.bio;
|
|
} else if (_.includes(context, 'tag') && data.tag) {
|
|
description = data.tag.meta_description || data.tag.description;
|
|
} else if ((_.includes(context, 'post') || _.includes(context, 'page')) && data.post) {
|
|
description = data.post.meta_description;
|
|
}
|
|
|
|
return (description || '').trim();
|
|
}
|
|
|
|
module.exports = getDescription;
|