06d91ce046
closes #6186 - Refactored ghost head helper to use the new metadata functions. - Fix issue where tag should output description if missing meta description. - Add test for tag description. - Updated tests to look for author urls with a tailing backslash - Fix author to output meta description first and then bio if missing.
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 (_.contains(context, 'paged')) {
|
|
description = '';
|
|
} else if (_.contains(context, 'home')) {
|
|
description = config.theme.description;
|
|
} else if (_.contains(context, 'author') && data.author) {
|
|
description = data.author.meta_description || data.author.bio;
|
|
} else if (_.contains(context, 'tag') && data.tag) {
|
|
description = data.tag.meta_description || data.tag.description;
|
|
} else if ((_.contains(context, 'post') || _.contains(context, 'page')) && data.post) {
|
|
description = data.post.meta_description;
|
|
}
|
|
|
|
return (description || '').trim();
|
|
}
|
|
|
|
module.exports = getDescription;
|