mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-19 08:31:43 +03:00
63723aa36a
closes #8037 🔥 Remove API-level default settings population - This is a relic! - We ALWAYS populate defaults on server start therefore this code could never run. - This was a lot of complicated code that wasn't even needed!! 🎨 Move settings cache - Move settings cache to be its own thing - Update all references - Adds TODOs for further cleanup 🎨 Create settings initialisation step - Create new settings library, which will eventually house more code - Unify the interface for initialising settings (will be more useful later) - Reduce number of calls to updateSettingsCache
27 lines
976 B
JavaScript
27 lines
976 B
JavaScript
var _ = require('lodash'),
|
|
settingsCache = require('../../settings/cache');
|
|
|
|
function getDescription(data, root) {
|
|
var description = '',
|
|
context = root ? root.context : null,
|
|
blogDescription = settingsCache.get('description');
|
|
|
|
if (data.meta_description) {
|
|
description = data.meta_description;
|
|
} else if (_.includes(context, 'paged')) {
|
|
description = '';
|
|
} else if (_.includes(context, 'home')) {
|
|
description = blogDescription;
|
|
} 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;
|