mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
🐛 Fixed meta schema for 'page' context in dynamic routing
refs #10082 - When specifying an existing page as an allias for collection, e.g: `data: page.it-is-a-page` it was failing to generate metadata
This commit is contained in:
parent
f5c1ed8fcb
commit
27dae4022c
1 changed files with 13 additions and 11 deletions
|
@ -38,15 +38,15 @@ function trimSchema(schema) {
|
|||
function trimSameAs(data, context) {
|
||||
var sameAs = [];
|
||||
|
||||
if (context === 'post') {
|
||||
if (data.post.primary_author.website) {
|
||||
sameAs.push(escapeExpression(data.post.primary_author.website));
|
||||
if (context === 'post' || context === 'page') {
|
||||
if (data[context].primary_author.website) {
|
||||
sameAs.push(escapeExpression(data[context].primary_author.website));
|
||||
}
|
||||
if (data.post.primary_author.facebook) {
|
||||
sameAs.push(social.urls.facebook(data.post.primary_author.facebook));
|
||||
if (data[context].primary_author.facebook) {
|
||||
sameAs.push(social.urls.facebook(data[context].primary_author.facebook));
|
||||
}
|
||||
if (data.post.primary_author.twitter) {
|
||||
sameAs.push(social.urls.twitter(data.post.primary_author.twitter));
|
||||
if (data[context].primary_author.twitter) {
|
||||
sameAs.push(social.urls.twitter(data[context].primary_author.twitter));
|
||||
}
|
||||
} else if (context === 'author') {
|
||||
if (data.author.website) {
|
||||
|
@ -69,6 +69,8 @@ function getPostSchema(metaData, data) {
|
|||
var description = metaData.excerpt ? escapeExpression(metaData.excerpt) : null,
|
||||
schema;
|
||||
|
||||
const context = data.page ? 'page' : 'post';
|
||||
|
||||
schema = {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'Article',
|
||||
|
@ -79,12 +81,12 @@ function getPostSchema(metaData, data) {
|
|||
},
|
||||
author: {
|
||||
'@type': 'Person',
|
||||
name: escapeExpression(data.post.primary_author.name),
|
||||
name: escapeExpression(data[context].primary_author.name),
|
||||
image: schemaImageObject(metaData.authorImage),
|
||||
url: metaData.authorUrl,
|
||||
sameAs: trimSameAs(data, 'post'),
|
||||
description: data.post.primary_author.metaDescription ?
|
||||
escapeExpression(data.post.primary_author.metaDescription) :
|
||||
sameAs: trimSameAs(data, context),
|
||||
description: data[context].primary_author.metaDescription ?
|
||||
escapeExpression(data[context].primary_author.metaDescription) :
|
||||
null
|
||||
},
|
||||
headline: escapeExpression(metaData.metaTitle),
|
||||
|
|
Loading…
Add table
Reference in a new issue