Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
structuredData = {
'og:site_name': metaData.site.title,
'og:type': metaData.ogType,
'og:title': metaData.ogTitle,
// CASE: metaData.excerpt for post context is populated by either the custom excerpt,
// the meta description, or the automated excerpt of 50 words. It is empty for any
// other context and *always* uses the provided meta description fields.
'og:description': metaData.ogDescription,
'og:url': metaData.canonicalUrl,
'og:image': metaData.ogImage.url || metaData.coverImage.url,
'article:published_time': metaData.publishedDate,
'article:modified_time': metaData.modifiedDate,
'article:tag': metaData.keywords,
'article:publisher': metaData.site.facebook ? socialUrls.facebook(metaData.site.facebook) : undefined,
'article:author': metaData.authorFacebook ? socialUrls.facebook(metaData.authorFacebook) : undefined,
'twitter:card': card,
'twitter:title': metaData.twitterTitle,
'twitter:description': metaData.twitterDescription,
'twitter:url': metaData.canonicalUrl,
'twitter:image': metaData.twitterImage || metaData.coverImage.url,
'twitter:label1': metaData.authorName ? 'Written by' : undefined,
'twitter:data1': metaData.authorName,
'twitter:label2': metaData.keywords ? 'Filed under' : undefined,
'twitter:data2': metaData.keywords ? metaData.keywords.join(', ') : undefined,
'twitter:site': metaData.site.twitter || undefined,
'twitter:creator': metaData.creatorTwitter || undefined
};
if (metaData.ogImage.dimensions) {
structuredData['og:image:width'] = metaData.ogImage.dimensions.width;
structuredData['og:image:height'] = metaData.ogImage.dimensions.height;
}
structuredData = {
'og:site_name': metaData.site.title,
'og:type': metaData.ogType,
'og:title': metaData.ogTitle,
// CASE: metaData.excerpt for post context is populated by either the custom excerpt,
// the meta description, or the automated excerpt of 50 words. It is empty for any
// other context and *always* uses the provided meta description fields.
'og:description': metaData.ogDescription,
'og:url': metaData.canonicalUrl,
'og:image': metaData.ogImage.url || metaData.coverImage.url,
'article:published_time': metaData.publishedDate,
'article:modified_time': metaData.modifiedDate,
'article:tag': metaData.keywords,
'article:publisher': metaData.site.facebook ? socialUrls.facebook(metaData.site.facebook) : undefined,
'article:author': metaData.authorFacebook ? socialUrls.facebook(metaData.authorFacebook) : undefined,
'twitter:card': card,
'twitter:title': metaData.twitterTitle,
'twitter:description': metaData.twitterDescription,
'twitter:url': metaData.canonicalUrl,
'twitter:image': metaData.twitterImage || metaData.coverImage.url,
'twitter:label1': metaData.authorName ? 'Written by' : undefined,
'twitter:data1': metaData.authorName,
'twitter:label2': metaData.keywords ? 'Filed under' : undefined,
'twitter:data2': metaData.keywords ? metaData.keywords.join(', ') : undefined,
'twitter:site': metaData.site.twitter || undefined,
'twitter:creator': metaData.creatorTwitter || undefined
};
if (metaData.ogImage.dimensions) {
structuredData['og:image:width'] = metaData.ogImage.dimensions.width;
function trimSameAs(data, context) {
var sameAs = [];
if (context === 'post' || context === 'page') {
if (data[context].primary_author.website) {
sameAs.push(escapeExpression(data[context].primary_author.website));
}
if (data[context].primary_author.facebook) {
sameAs.push(socialUrls.facebook(data[context].primary_author.facebook));
}
if (data[context].primary_author.twitter) {
sameAs.push(socialUrls.twitter(data[context].primary_author.twitter));
}
} else if (context === 'author') {
if (data.author.website) {
sameAs.push(escapeExpression(data.author.website));
}
if (data.author.facebook) {
sameAs.push(socialUrls.facebook(data.author.facebook));
}
if (data.author.twitter) {
sameAs.push(socialUrls.twitter(data.author.twitter));
}
}
if (context === 'post' || context === 'page') {
if (data[context].primary_author.website) {
sameAs.push(escapeExpression(data[context].primary_author.website));
}
if (data[context].primary_author.facebook) {
sameAs.push(socialUrls.facebook(data[context].primary_author.facebook));
}
if (data[context].primary_author.twitter) {
sameAs.push(socialUrls.twitter(data[context].primary_author.twitter));
}
} else if (context === 'author') {
if (data.author.website) {
sameAs.push(escapeExpression(data.author.website));
}
if (data.author.facebook) {
sameAs.push(socialUrls.facebook(data.author.facebook));
}
if (data.author.twitter) {
sameAs.push(socialUrls.twitter(data.author.twitter));
}
}
return sameAs;
}
}
if (data[context].primary_author.facebook) {
sameAs.push(socialUrls.facebook(data[context].primary_author.facebook));
}
if (data[context].primary_author.twitter) {
sameAs.push(socialUrls.twitter(data[context].primary_author.twitter));
}
} else if (context === 'author') {
if (data.author.website) {
sameAs.push(escapeExpression(data.author.website));
}
if (data.author.facebook) {
sameAs.push(socialUrls.facebook(data.author.facebook));
}
if (data.author.twitter) {
sameAs.push(socialUrls.twitter(data.author.twitter));
}
}
return sameAs;
}
function trimSameAs(data, context) {
var sameAs = [];
if (context === 'post' || context === 'page') {
if (data[context].primary_author.website) {
sameAs.push(escapeExpression(data[context].primary_author.website));
}
if (data[context].primary_author.facebook) {
sameAs.push(socialUrls.facebook(data[context].primary_author.facebook));
}
if (data[context].primary_author.twitter) {
sameAs.push(socialUrls.twitter(data[context].primary_author.twitter));
}
} else if (context === 'author') {
if (data.author.website) {
sameAs.push(escapeExpression(data.author.website));
}
if (data.author.facebook) {
sameAs.push(socialUrls.facebook(data.author.facebook));
}
if (data.author.twitter) {
sameAs.push(socialUrls.twitter(data.author.twitter));
}
}
return sameAs;
}