mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Updated frontend meta helpers to support tag metadata (#12037)
no-issue - `canonicalUrl` - Updated to use `canonical_url` & fall back to previous functionality - `ogTitle` - Updated to use `og_title` and fall back to previous functionality - `ogImage` - Updated to use `og_image` and fall back to previous functionality - `ogDescription` - Updated to use `og_description` and fall back to previous functionality - `twitterTitle` - Updated to use `twitter_title` and fall back to previous functionality - `twitterImage` - Upated to use `twitter_image` and fall back to previous functionality - `twitterDescription` - Updated to use `twitter_description` and fall back to previous functionality
This commit is contained in:
parent
d6267340a1
commit
2dd302a23e
5 changed files with 13 additions and 4 deletions
|
@ -8,6 +8,10 @@ function getCanonicalUrl(data) {
|
|||
return data.post.canonical_url;
|
||||
}
|
||||
|
||||
if (_.includes(data.context, 'tag') && data.tag && data.tag.canonical_url) {
|
||||
return data.tag.canonical_url;
|
||||
}
|
||||
|
||||
let url = urlUtils.urlJoin(urlUtils.urlFor('home', true), getUrl(data, false));
|
||||
|
||||
if (url.indexOf('/amp/')) {
|
||||
|
|
|
@ -36,7 +36,8 @@ function getDescription(data, root, options = {}) {
|
|||
if (!options.property && _.includes(context, 'paged')) {
|
||||
description = '';
|
||||
} else {
|
||||
description = data.tag.meta_description
|
||||
description = data.tag[`${options.property}_description`]
|
||||
|| data.tag.meta_description
|
||||
|| data.tag.description
|
||||
|| (options.property ? settingsCache.get('meta_description') : '')
|
||||
|| '';
|
||||
|
|
|
@ -25,7 +25,9 @@ function getOgImage(data) {
|
|||
}
|
||||
|
||||
if (_.includes(context, 'tag')) {
|
||||
if (contextObject.feature_image) {
|
||||
if (contextObject.og_image) {
|
||||
return urlUtils.relativeToAbsolute(contextObject.og_image);
|
||||
} else if (contextObject.feature_image) {
|
||||
return urlUtils.relativeToAbsolute(contextObject.feature_image);
|
||||
} else if (settingsCache.get('cover_image')) {
|
||||
return urlUtils.relativeToAbsolute(settingsCache.get('cover_image'));
|
||||
|
|
|
@ -37,7 +37,7 @@ function getTitle(data, root, options = {}) {
|
|||
title = data.tag.meta_title || data.tag.name + ' - ' + siteTitle + pageString;
|
||||
// Tag title, index
|
||||
} else if (_.includes(context, 'tag') && data.tag) {
|
||||
title = data.tag.meta_title || data.tag.name + ' - ' + siteTitle;
|
||||
title = data.tag[optionsPropertyName] || data.tag.meta_title || data.tag.name + ' - ' + siteTitle;
|
||||
// Post title
|
||||
} else if (_.includes(context, 'post') && data.post) {
|
||||
title = data.post[optionsPropertyName] || data.post.meta_title || data.post.title;
|
||||
|
|
|
@ -25,7 +25,9 @@ function getTwitterImage(data) {
|
|||
}
|
||||
|
||||
if (_.includes(context, 'tag')) {
|
||||
if (contextObject.feature_image) {
|
||||
if (contextObject.twitter_image) {
|
||||
return urlUtils.relativeToAbsolute(contextObject.twitter_image);
|
||||
} else if (contextObject.feature_image) {
|
||||
return urlUtils.relativeToAbsolute(contextObject.feature_image);
|
||||
} else if (settingsCache.get('cover_image')) {
|
||||
return urlUtils.relativeToAbsolute(settingsCache.get('cover_image'));
|
||||
|
|
Loading…
Add table
Reference in a new issue