🐛 Fixed broken structured data previews

closes https://github.com/TryGhost/Ghost/issues/11385

- Updates og and twitter description to use correct fallbacks for posts/pages
- Updates og and twitter description to use correct fallback for tags
- Updates og and twitter title to use correct name format for tags
This commit is contained in:
Rish 2020-07-14 16:44:02 +05:30 committed by Rishabh Garg
parent 63ea14327a
commit a38d7ddb19
2 changed files with 8 additions and 5 deletions

View File

@ -40,10 +40,10 @@ export default Component.extend(SettingsMenuMixin, {
twitterTitleScratch: alias('post.twitterTitleScratch'),
slugValue: boundOneWay('post.slug'),
facebookDescription: or('ogDescriptionScratch', 'customExcerptScratch', 'seoDescription'),
facebookDescription: or('ogDescriptionScratch', 'customExcerptScratch', 'seoDescription', 'post.excerpt', 'settings.description', ''),
facebookImage: or('post.ogImage', 'post.featureImage'),
facebookTitle: or('ogTitleScratch', 'seoTitle'),
twitterDescription: or('twitterDescriptionScratch', 'customExcerptScratch', 'seoDescription'),
twitterDescription: or('twitterDescriptionScratch', 'customExcerptScratch', 'seoDescription', 'post.excerpt', 'settings.description', ''),
twitterImage: or('post.twitterImage', 'post.featureImage'),
twitterTitle: or('twitterTitleScratch', 'seoTitle'),

View File

@ -11,6 +11,7 @@ const {Handlebars} = Ember;
export default Component.extend({
feature: service(),
config: service(),
settings: service(),
tag: null,
scratchTag: null,
@ -19,11 +20,11 @@ export default Component.extend({
setProperty: () => {},
twitterTitle: or('scratchTag.twitterTitle', 'seoTitle'),
twitterDescription: or('scratchTag.twitterDescription', 'seoDescription'),
twitterDescription: or('scratchTag.twitterDescription', 'seoDescription', 'settings.metaDescription', ''),
twitterImage: or('tag.twitterImage', 'tag.featureImage'),
facebookTitle: or('scratchTag.ogTitle', 'seoTitle'),
facebookDescription: or('scratchTag.ogDescription', 'seoDescription'),
facebookDescription: or('scratchTag.ogDescription', 'seoDescription', 'settings.metaDescription', ''),
facebookImage: or('tag.ogImage', 'tag.featureImage'),
accentColor: computed('tag.accentColor', function () {
@ -48,7 +49,9 @@ export default Component.extend({
}),
seoTitle: computed('scratchTag.{name,metaTitle}', function () {
let metaTitle = this.scratchTag.metaTitle || this.scratchTag.name;
const settingsTitle = this.get('settings.title') || '';
const tagName = settingsTitle ? `${this.scratchTag.name} - ${settingsTitle}` : this.scratchTag.name;
let metaTitle = this.scratchTag.metaTitle || tagName;
if (metaTitle && metaTitle.length > 70) {
metaTitle = metaTitle.substring(0, 70).trim();