mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 02:11:44 +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
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
var _ = require('lodash'),
|
|
settingsCache = require('../../settings/cache');
|
|
|
|
function getTitle(data, root) {
|
|
var title = '',
|
|
context = root ? root.context : null,
|
|
blogTitle = settingsCache.get('title'),
|
|
pagination = root ? root.pagination : null,
|
|
pageString = '';
|
|
|
|
if (pagination && pagination.total > 1) {
|
|
pageString = ' - Page ' + pagination.page;
|
|
}
|
|
|
|
if (data.meta_title) {
|
|
title = data.meta_title;
|
|
} else if (_.includes(context, 'home')) {
|
|
title = blogTitle;
|
|
} else if (_.includes(context, 'author') && data.author) {
|
|
title = data.author.name + pageString + ' - ' + blogTitle;
|
|
} else if (_.includes(context, 'tag') && data.tag) {
|
|
title = data.tag.meta_title || data.tag.name + pageString + ' - ' + blogTitle;
|
|
} else if ((_.includes(context, 'post') || _.includes(context, 'page')) && data.post) {
|
|
title = data.post.meta_title || data.post.title;
|
|
} else {
|
|
title = blogTitle + pageString;
|
|
}
|
|
|
|
return (title || '').trim();
|
|
}
|
|
|
|
module.exports = getTitle;
|