@quintype/seo 1.50.1 → 1.50.2-aff-mkt-template.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js
CHANGED
|
@@ -1060,6 +1060,7 @@ function StructuredDataTags({ structuredData = {} }, config, pageType, response
|
|
|
1060
1060
|
const structuredDataTags = get__default["default"](structuredData, ["structuredDataTags"], []);
|
|
1061
1061
|
const enableEventsData = get__default["default"](structuredData, ["enableEventsData"], null);
|
|
1062
1062
|
const enableStorySeoEventsData = get__default["default"](story, ["enableSeoEventsData"], null);
|
|
1063
|
+
const enableAffiliateMarketing = get__default["default"](structuredData, ["enableAffiliateMarketing"], false);
|
|
1063
1064
|
let articleData = {};
|
|
1064
1065
|
|
|
1065
1066
|
if (!isStructuredDataEmpty) {
|
|
@@ -1094,6 +1095,13 @@ function StructuredDataTags({ structuredData = {} }, config, pageType, response
|
|
|
1094
1095
|
newsArticleTags ? tags.push(storyTags(), newsArticleTags) : tags.push(storyTags());
|
|
1095
1096
|
}
|
|
1096
1097
|
|
|
1098
|
+
if (enableAffiliateMarketing && !isStructuredDataEmpty && pageType === "story-page" && story["story-template"] === "affiliate-marketing") {
|
|
1099
|
+
const affiliateProductTags = generateAffiliateProductData();
|
|
1100
|
+
if (affiliateProductTags) {
|
|
1101
|
+
tags.push(...affiliateProductTags);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1097
1105
|
if (!isStructuredDataEmpty && pageType === "story-page-amp") {
|
|
1098
1106
|
const newsArticleTags = generateNewsArticleTags();
|
|
1099
1107
|
newsArticleTags ? tags.push(storyTags(), newsArticleTags) : tags.push(storyTags());
|
|
@@ -1187,6 +1195,49 @@ function StructuredDataTags({ structuredData = {} }, config, pageType, response
|
|
|
1187
1195
|
return ldJson("MediaGallery", schema);
|
|
1188
1196
|
}
|
|
1189
1197
|
|
|
1198
|
+
function generateAffiliateProductData() {
|
|
1199
|
+
const storyUrl = story.url || `${publisherConfig["sketches-host"]}/${story.slug}`;
|
|
1200
|
+
const authorName = get__default["default"](story, ["authors", 0, "name"]) || story["author-name"] || "";
|
|
1201
|
+
const datePublished = stripMillisecondsFromTime(new Date(story["first-published-at"]), timezone);
|
|
1202
|
+
const cards = get__default["default"](story, ["cards"], []);
|
|
1203
|
+
|
|
1204
|
+
const products = cards.reduce((acc, card) => {
|
|
1205
|
+
const elements = get__default["default"](card, ["story-elements"], []);
|
|
1206
|
+
let titleEl, imageEl, ctaEl, textEl;
|
|
1207
|
+
for (const el of elements) {
|
|
1208
|
+
if (!titleEl && el.type === "title") titleEl = el;else if (!imageEl && el.type === "image") imageEl = el;else if (!ctaEl && el.type === "text" && el.subtype === "cta") ctaEl = el;else if (!textEl && el.type === "text" && el.subtype !== "cta") textEl = el;
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
if (!titleEl) return acc;
|
|
1212
|
+
|
|
1213
|
+
const name = getPlainText(titleEl.text || titleEl.title || "");
|
|
1214
|
+
if (!name) return acc;
|
|
1215
|
+
|
|
1216
|
+
const reviewBody = getPlainText(get__default["default"](textEl, ["text"], ""));
|
|
1217
|
+
const ctaUrl = get__default["default"](ctaEl, ["metadata", "cta-url"]);
|
|
1218
|
+
|
|
1219
|
+
const product = {
|
|
1220
|
+
name,
|
|
1221
|
+
url: ctaUrl || `${storyUrl}#${card.id}`,
|
|
1222
|
+
review: {
|
|
1223
|
+
"@type": "Review",
|
|
1224
|
+
author: getSchemaPerson(authorName),
|
|
1225
|
+
reviewBody,
|
|
1226
|
+
datePublished
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1229
|
+
|
|
1230
|
+
if (imageEl && imageEl["image-s3-key"]) {
|
|
1231
|
+
product.image = imageUrl(publisherConfig, imageEl["image-s3-key"]);
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
acc.push(ldJson("Product", product));
|
|
1235
|
+
return acc;
|
|
1236
|
+
}, []);
|
|
1237
|
+
|
|
1238
|
+
return products.length ? products : null;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1190
1241
|
// All Pages have: Publisher, Site
|
|
1191
1242
|
// Story Page have : Article/NewsArticle/LiveBlog/Review as appropriate
|
|
1192
1243
|
return tags;
|
package/package.json
CHANGED
|
@@ -564,6 +564,7 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re
|
|
|
564
564
|
const structuredDataTags = get(structuredData, ["structuredDataTags"], []);
|
|
565
565
|
const enableEventsData = get(structuredData, ["enableEventsData"], null);
|
|
566
566
|
const enableStorySeoEventsData = get(story, ["enableSeoEventsData"], null);
|
|
567
|
+
const enableAffiliateMarketing = get(structuredData, ["enableAffiliateMarketing"], false);
|
|
567
568
|
let articleData = {};
|
|
568
569
|
|
|
569
570
|
if (!isStructuredDataEmpty) {
|
|
@@ -598,6 +599,13 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re
|
|
|
598
599
|
newsArticleTags ? tags.push(storyTags(), newsArticleTags) : tags.push(storyTags());
|
|
599
600
|
}
|
|
600
601
|
|
|
602
|
+
if (enableAffiliateMarketing && !isStructuredDataEmpty && pageType === "story-page" && story["story-template"] === "affiliate-marketing") {
|
|
603
|
+
const affiliateProductTags = generateAffiliateProductData();
|
|
604
|
+
if (affiliateProductTags) {
|
|
605
|
+
tags.push(...affiliateProductTags);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
601
609
|
if (!isStructuredDataEmpty && pageType === "story-page-amp") {
|
|
602
610
|
const newsArticleTags = generateNewsArticleTags();
|
|
603
611
|
newsArticleTags ? tags.push(storyTags(), newsArticleTags) : tags.push(storyTags());
|
|
@@ -700,6 +708,52 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re
|
|
|
700
708
|
return ldJson("MediaGallery", schema);
|
|
701
709
|
}
|
|
702
710
|
|
|
711
|
+
function generateAffiliateProductData() {
|
|
712
|
+
const storyUrl = story.url || `${publisherConfig["sketches-host"]}/${story.slug}`;
|
|
713
|
+
const authorName = get(story, ["authors", 0, "name"]) || story["author-name"] || "";
|
|
714
|
+
const datePublished = stripMillisecondsFromTime(new Date(story["first-published-at"]), timezone);
|
|
715
|
+
const cards = get(story, ["cards"], []);
|
|
716
|
+
|
|
717
|
+
const products = cards.reduce((acc, card) => {
|
|
718
|
+
const elements = get(card, ["story-elements"], []);
|
|
719
|
+
let titleEl, imageEl, ctaEl, textEl;
|
|
720
|
+
for (const el of elements) {
|
|
721
|
+
if (!titleEl && el.type === "title") titleEl = el;
|
|
722
|
+
else if (!imageEl && el.type === "image") imageEl = el;
|
|
723
|
+
else if (!ctaEl && el.type === "text" && el.subtype === "cta") ctaEl = el;
|
|
724
|
+
else if (!textEl && el.type === "text" && el.subtype !== "cta") textEl = el;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
if (!titleEl) return acc;
|
|
728
|
+
|
|
729
|
+
const name = getPlainText(titleEl.text || titleEl.title || "");
|
|
730
|
+
if (!name) return acc;
|
|
731
|
+
|
|
732
|
+
const reviewBody = getPlainText(get(textEl, ["text"], ""));
|
|
733
|
+
const ctaUrl = get(ctaEl, ["metadata", "cta-url"]);
|
|
734
|
+
|
|
735
|
+
const product = {
|
|
736
|
+
name,
|
|
737
|
+
url: ctaUrl || `${storyUrl}#${card.id}`,
|
|
738
|
+
review: {
|
|
739
|
+
"@type": "Review",
|
|
740
|
+
author: getSchemaPerson(authorName),
|
|
741
|
+
reviewBody,
|
|
742
|
+
datePublished,
|
|
743
|
+
},
|
|
744
|
+
};
|
|
745
|
+
|
|
746
|
+
if (imageEl && imageEl["image-s3-key"]) {
|
|
747
|
+
product.image = imageUrl(publisherConfig, imageEl["image-s3-key"]);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
acc.push(ldJson("Product", product));
|
|
751
|
+
return acc;
|
|
752
|
+
}, []);
|
|
753
|
+
|
|
754
|
+
return products.length ? products : null;
|
|
755
|
+
}
|
|
756
|
+
|
|
703
757
|
// All Pages have: Publisher, Site
|
|
704
758
|
// Story Page have : Article/NewsArticle/LiveBlog/Review as appropriate
|
|
705
759
|
return tags;
|