@quintype/seo 1.40.2 → 1.40.3-update-image-schema.0
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 +45 -45
- package/package.json +3 -3
- package/src/image-tags.js +1 -0
- package/src/structured-data/structured-data-tags.js +27 -28
- package/test/structured_data_tags_test.js +198 -200
package/dist/index.cjs.js
CHANGED
|
@@ -449,6 +449,7 @@ function pickImage({ pageType, config, seoConfig, data, url }) {
|
|
|
449
449
|
* @param {*} seoConfig
|
|
450
450
|
* @param {boolean} seoConfig.enableOgTags Add og tags for Facebook
|
|
451
451
|
* @param {boolean} seoConfig.enableTwitterCards Add twitter tags
|
|
452
|
+
* @param {string} seoConfig.fallbackSocialImage Optional. Should be full URL (i.e. include https://). This image will be shown in og:image and twitter:image meta tags for stories having no hero image or alternate hero/social images
|
|
452
453
|
* @param {...*} params See {@link Generator} for other Parameters
|
|
453
454
|
*/
|
|
454
455
|
function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
|
|
@@ -622,12 +623,12 @@ function imageUrl(publisherConfig, s3Key, width, height) {
|
|
|
622
623
|
return `${imageSrc}/${s3Key}?w=${width}&h=${height}&auto=format%2Ccompress&fit=max`;
|
|
623
624
|
}
|
|
624
625
|
|
|
625
|
-
function generateCommonData(structuredData = {}, story = {}, publisherConfig = {},
|
|
626
|
+
function generateCommonData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
|
|
626
627
|
const storyUrl = story.url || `${publisherConfig["sketches-host"]}/${story.slug}`;
|
|
627
|
-
const orgUrl = get__default[
|
|
628
|
-
const mainEntityUrl = Object.keys(story).length > 0 && structuredData.storyUrlAsMainEntityUrl ? storyUrl : get__default[
|
|
629
|
-
const imageWidth =
|
|
630
|
-
const imageHeight =
|
|
628
|
+
const orgUrl = get__default["default"](structuredData, ["organization", "url"], "");
|
|
629
|
+
const mainEntityUrl = Object.keys(story).length > 0 && structuredData.storyUrlAsMainEntityUrl ? storyUrl : get__default["default"](structuredData, ["organization", "url"], "");
|
|
630
|
+
const imageWidth = 1200; // This value is updated based on latest google requirement
|
|
631
|
+
const imageHeight = 675; // This value is updated based on latest google requirement
|
|
631
632
|
return Object.assign({}, {
|
|
632
633
|
headline: story.headline,
|
|
633
634
|
image: [imageUrl(publisherConfig, story["hero-image-s3-key"], imageWidth, imageHeight)],
|
|
@@ -670,20 +671,20 @@ function getCompleteText(story, stripHtmlFromArticleBody) {
|
|
|
670
671
|
|
|
671
672
|
function articleSectionObj(story) {
|
|
672
673
|
if (story["story-template"] !== "video") {
|
|
673
|
-
return { articleSection: get__default[
|
|
674
|
+
return { articleSection: get__default["default"](story, ["sections", "0", "display-name"], "") };
|
|
674
675
|
}
|
|
675
676
|
}
|
|
676
677
|
|
|
677
|
-
function generateArticleData(structuredData = {}, story = {}, publisherConfig = {},
|
|
678
|
+
function generateArticleData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
|
|
678
679
|
const metaKeywords = story.seo && story.seo["meta-keywords"] || [];
|
|
679
680
|
const authors = story.authors && story.authors.length !== 0 ? story.authors : [{ name: story["author-name"] || "" }];
|
|
680
681
|
const storyKeysPresence = Object.keys(story).length > 0;
|
|
681
|
-
const imageWidth =
|
|
682
|
-
const imageHeight =
|
|
682
|
+
const imageWidth = 1200; // This value is updated based on latest google requirement
|
|
683
|
+
const imageHeight = 675; // This value is updated based on latest google requirement
|
|
683
684
|
const storyAccessType = storyAccess(story["access"]);
|
|
684
685
|
const authorSchema = structuredData.authorSchema && structuredData.authorSchema(story) || [];
|
|
685
686
|
|
|
686
|
-
return Object.assign({}, generateCommonData(structuredData, story, publisherConfig,
|
|
687
|
+
return Object.assign({}, generateCommonData(structuredData, story, publisherConfig, timezone), {
|
|
687
688
|
author: authorData(authors, authorSchema, publisherConfig),
|
|
688
689
|
keywords: metaKeywords.join(","),
|
|
689
690
|
thumbnailUrl: imageUrl(publisherConfig, story["hero-image-s3-key"], imageWidth, imageHeight),
|
|
@@ -691,15 +692,15 @@ function generateArticleData(structuredData = {}, story = {}, publisherConfig =
|
|
|
691
692
|
dateCreated: stripMillisecondsFromTime(new Date(story["first-published-at"]), timezone),
|
|
692
693
|
dateModified: stripMillisecondsFromTime(new Date(story["last-published-at"]), timezone),
|
|
693
694
|
name: storyKeysPresence && story.headline || "",
|
|
694
|
-
image: generateArticleImageData(story["hero-image-s3-key"], publisherConfig
|
|
695
|
+
image: generateArticleImageData(story["hero-image-s3-key"], publisherConfig),
|
|
695
696
|
isAccessibleForFree: storyAccessType,
|
|
696
|
-
isPartOf: generateIsPartOfDataForArticle(story, publisherConfig
|
|
697
|
+
isPartOf: generateIsPartOfDataForArticle(story, publisherConfig)
|
|
697
698
|
}, articleSectionObj(story));
|
|
698
699
|
}
|
|
699
700
|
|
|
700
|
-
function generateArticleImageData(image, publisherConfig = {}
|
|
701
|
-
const imageWidth =
|
|
702
|
-
const imageHeight =
|
|
701
|
+
function generateArticleImageData(image, publisherConfig = {}) {
|
|
702
|
+
const imageWidth = 1200; // This value is updated based on latest google requirement
|
|
703
|
+
const imageHeight = 675; // This value is updated based on latest google requirement
|
|
703
704
|
const articleImage = imageUrl(publisherConfig, image, imageWidth, imageHeight);
|
|
704
705
|
|
|
705
706
|
return Object.assign({}, {
|
|
@@ -716,18 +717,18 @@ function storyAccess(access) {
|
|
|
716
717
|
}
|
|
717
718
|
}
|
|
718
719
|
|
|
719
|
-
function generateIsPartOfDataForArticle(story = {}, publisherConfig = {}
|
|
720
|
+
function generateIsPartOfDataForArticle(story = {}, publisherConfig = {}) {
|
|
720
721
|
return Object.assign({}, {
|
|
721
722
|
"@type": "WebPage",
|
|
722
723
|
url: `${publisherConfig["sketches-host"]}/${story.slug}`,
|
|
723
|
-
primaryImageOfPage: generateArticleImageData(story["hero-image-s3-key"], publisherConfig
|
|
724
|
+
primaryImageOfPage: generateArticleImageData(story["hero-image-s3-key"], publisherConfig)
|
|
724
725
|
});
|
|
725
726
|
}
|
|
726
727
|
|
|
727
728
|
function generateIsPartOfDataForNewsArticle(story = {}, publisherConfig = {}, pageType = "", structuredData = {}) {
|
|
728
729
|
const publisherName = publisherConfig["publisher-name"];
|
|
729
730
|
const productId = `${publisherConfig["publisher-name"]}${structuredData.isShowcaseProduct ? ".com:showcase" : ".com:basic"}`;
|
|
730
|
-
const isPartOfData = generateIsPartOfDataForArticle(story, publisherConfig
|
|
731
|
+
const isPartOfData = generateIsPartOfDataForArticle(story, publisherConfig);
|
|
731
732
|
|
|
732
733
|
if (structuredData.isSubscriptionsEnabled) {
|
|
733
734
|
return Object.assign(isPartOfData, {
|
|
@@ -743,7 +744,7 @@ function generateIsPartOfDataForNewsArticle(story = {}, publisherConfig = {}, pa
|
|
|
743
744
|
name: publisherName,
|
|
744
745
|
productID: productId,
|
|
745
746
|
url: `${publisherConfig["sketches-host"]}/${story.slug}`,
|
|
746
|
-
primaryImageOfPage: generateArticleImageData(story["hero-image-s3-key"], publisherConfig
|
|
747
|
+
primaryImageOfPage: generateArticleImageData(story["hero-image-s3-key"], publisherConfig)
|
|
747
748
|
});
|
|
748
749
|
}
|
|
749
750
|
return isPartOfData;
|
|
@@ -775,9 +776,9 @@ function findStoryElementField(card, type, field, defaultValue) {
|
|
|
775
776
|
if (elements.length > 0) return elements[0][field];else return defaultValue;
|
|
776
777
|
}
|
|
777
778
|
|
|
778
|
-
function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherConfig = {},
|
|
779
|
-
const imageWidth =
|
|
780
|
-
const imageHeight =
|
|
779
|
+
function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
|
|
780
|
+
const imageWidth = 1200; // This value is updated based on latest google requirement
|
|
781
|
+
const imageHeight = 675; // This value is updated based on latest google requirement
|
|
781
782
|
const authorSchema = structuredData.authorSchema && structuredData.authorSchema(story) || [];
|
|
782
783
|
return {
|
|
783
784
|
headline: story.headline,
|
|
@@ -790,18 +791,17 @@ function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherC
|
|
|
790
791
|
};
|
|
791
792
|
}
|
|
792
793
|
|
|
793
|
-
function generateVideoArticleData(structuredData = {}, story = {}, publisherConfig = {},
|
|
794
|
+
function generateVideoArticleData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
|
|
794
795
|
const metaKeywords = story.seo && story.seo["meta-keywords"] || [];
|
|
795
|
-
get__default[
|
|
796
|
-
const
|
|
797
|
-
const
|
|
798
|
-
const
|
|
799
|
-
const
|
|
800
|
-
const
|
|
801
|
-
const
|
|
802
|
-
const imageHeight = pageType === "story-page-amp" ? "750" : "270";
|
|
796
|
+
const embedUrl = get__default["default"](story, ["cards", "0", "story-elements", "0", "embed-url"], "");
|
|
797
|
+
const socialShareMsg = get__default["default"](story, ["summary"], "");
|
|
798
|
+
const metaDescription = get__default["default"](story, ["seo", "meta-description"], "");
|
|
799
|
+
const subHeadline = get__default["default"](story, ["subheadline"], "");
|
|
800
|
+
const headline = get__default["default"](story, ["headline"], "");
|
|
801
|
+
const imageWidth = 1200; // This value is updated based on latest google requirement
|
|
802
|
+
const imageHeight = 675; // This value is updated based on latest google requirement
|
|
803
803
|
const authorSchema = structuredData.authorSchema && structuredData.authorSchema(story) || [];
|
|
804
|
-
return Object.assign({}, generateCommonData(structuredData, story, publisherConfig,
|
|
804
|
+
return Object.assign({}, generateCommonData(structuredData, story, publisherConfig, timezone), {
|
|
805
805
|
author: authorData(story.authors, authorSchema, publisherConfig),
|
|
806
806
|
keywords: metaKeywords.join(","),
|
|
807
807
|
dateCreated: stripMillisecondsFromTime(new Date(story["first-published-at"]), timezone),
|
|
@@ -938,17 +938,17 @@ function generateBreadcrumbListData(pageType = "", publisherConfig = {}, data =
|
|
|
938
938
|
function StructuredDataTags({ structuredData = {} }, config, pageType, response = {}, { url }) {
|
|
939
939
|
const tags = [];
|
|
940
940
|
const { story = {}, timezone = null } = response.data || {};
|
|
941
|
-
const entities = get__default[
|
|
941
|
+
const entities = get__default["default"](response, ["data", "linkedEntities"], null) || [];
|
|
942
942
|
const { config: publisherConfig = {} } = response;
|
|
943
943
|
publisherConfig["publisher-settings"] || {};
|
|
944
944
|
const isStructuredDataEmpty = Object.keys(structuredData).length === 0;
|
|
945
|
-
const enableBreadcrumbList = get__default[
|
|
946
|
-
const structuredDataTags = get__default[
|
|
945
|
+
const enableBreadcrumbList = get__default["default"](structuredData, ["enableBreadcrumbList"], true);
|
|
946
|
+
const structuredDataTags = get__default["default"](structuredData, ["structuredDataTags"], []);
|
|
947
947
|
|
|
948
948
|
let articleData = {};
|
|
949
949
|
|
|
950
950
|
if (!isStructuredDataEmpty) {
|
|
951
|
-
articleData = generateArticleData(structuredData, story, publisherConfig,
|
|
951
|
+
articleData = generateArticleData(structuredData, story, publisherConfig, timezone);
|
|
952
952
|
structuredDataTags.map(type => {
|
|
953
953
|
if (pageType === type) {
|
|
954
954
|
tags.push(ldJson("Organization", structuredData.organization));
|
|
@@ -1003,11 +1003,11 @@ function StructuredDataTags({ structuredData = {} }, config, pageType, response
|
|
|
1003
1003
|
|
|
1004
1004
|
function storyTags() {
|
|
1005
1005
|
if (structuredData.enableLiveBlog && story["story-template"] === "live-blog") {
|
|
1006
|
-
return ldJson("LiveBlogPosting", Object.assign({}, generateLiveBlogPostingData(structuredData, story, publisherConfig,
|
|
1006
|
+
return ldJson("LiveBlogPosting", Object.assign({}, generateLiveBlogPostingData(structuredData, story, publisherConfig, timezone)));
|
|
1007
1007
|
}
|
|
1008
1008
|
|
|
1009
1009
|
if (structuredData.enableVideo && story["story-template"] === "video") {
|
|
1010
|
-
return ldJson("VideoObject", generateVideoArticleData(structuredData, story, publisherConfig,
|
|
1010
|
+
return ldJson("VideoObject", generateVideoArticleData(structuredData, story, publisherConfig, timezone));
|
|
1011
1011
|
}
|
|
1012
1012
|
|
|
1013
1013
|
if (structuredData.enableNewsArticle !== "withoutArticleSchema") {
|
|
@@ -1026,7 +1026,7 @@ function showAmpTag({ ampStoryPages = true }, pageType, story) {
|
|
|
1026
1026
|
return false;
|
|
1027
1027
|
}
|
|
1028
1028
|
|
|
1029
|
-
if (!get__default[
|
|
1029
|
+
if (!get__default["default"](story, ["is-amp-supported"])) {
|
|
1030
1030
|
return false;
|
|
1031
1031
|
}
|
|
1032
1032
|
|
|
@@ -1058,7 +1058,7 @@ const getDomain = (url, domainSlug) => {
|
|
|
1058
1058
|
*/
|
|
1059
1059
|
function StoryAmpTags(seoConfig, config, pageType, data = {}, opts) {
|
|
1060
1060
|
|
|
1061
|
-
const story = get__default[
|
|
1061
|
+
const story = get__default["default"](data, ["data", "story"], {});
|
|
1062
1062
|
const { currentHostUrl = '', domainSlug } = data;
|
|
1063
1063
|
// TODO: Remove this condition and always make absolute URL if that's better for AMP discoverability.
|
|
1064
1064
|
const ampUrlAppend = seoConfig.appendHostToAmpUrl ? getDomain(currentHostUrl, domainSlug) || config['sketches-host'] : '';
|
|
@@ -1081,7 +1081,7 @@ function getTitle(config) {
|
|
|
1081
1081
|
function generateStaticData(config) {
|
|
1082
1082
|
const title = getTitle(config);
|
|
1083
1083
|
const themeConfig = config["theme-attributes"] || {};
|
|
1084
|
-
const publicIntegrations = get__default[
|
|
1084
|
+
const publicIntegrations = get__default["default"](config, ['public-integrations'], {});
|
|
1085
1085
|
const staticData = {
|
|
1086
1086
|
"twitter:site": title,
|
|
1087
1087
|
"twitter:domain": config["sketches-host"],
|
|
@@ -1092,12 +1092,12 @@ function generateStaticData(config) {
|
|
|
1092
1092
|
"twitter:app:id:iphone": themeConfig["twitter_app_id_iphone"],
|
|
1093
1093
|
"apple-itunes-app": themeConfig["apple_itunes_app"],
|
|
1094
1094
|
"google-play-app": themeConfig["google_play_app"],
|
|
1095
|
-
"fb:app_id": get__default[
|
|
1095
|
+
"fb:app_id": get__default["default"](publicIntegrations, ['facebook', 'app-id']) || get__default["default"](themeConfig, ["fb_app_id"]),
|
|
1096
1096
|
"fb:pages": themeConfig["fb_pages"],
|
|
1097
1097
|
"og:site_name": title
|
|
1098
1098
|
};
|
|
1099
1099
|
|
|
1100
|
-
return omitBy__default[
|
|
1100
|
+
return omitBy__default["default"](staticData, isUndefined__default["default"]);
|
|
1101
1101
|
}
|
|
1102
1102
|
|
|
1103
1103
|
function generateImageObject(config = {}) {
|
|
@@ -1118,7 +1118,7 @@ function generateStructuredData(config = {}) {
|
|
|
1118
1118
|
const title = getTitle(config);
|
|
1119
1119
|
const { "theme-attributes": themeConfig, "social-links": socialLinks, "seo-metadata": seoMetadata = [] } = config;
|
|
1120
1120
|
const homePageSeo = seoMetadata.find(page => page["owner-type"] === "home") || {};
|
|
1121
|
-
const { "page-title": pageTitle = "", description = "", keywords = "" } = get__default[
|
|
1121
|
+
const { "page-title": pageTitle = "", description = "", keywords = "" } = get__default["default"](homePageSeo, ["data"], {});
|
|
1122
1122
|
if (!themeConfig || !themeConfig.logo) {
|
|
1123
1123
|
return {};
|
|
1124
1124
|
}
|
|
@@ -1169,7 +1169,7 @@ class MetaTagList {
|
|
|
1169
1169
|
|
|
1170
1170
|
toString() {
|
|
1171
1171
|
const uniqueTags = lodash.uniqBy(this.tags.reverse(), tagToKey).reverse();
|
|
1172
|
-
return ReactDomServer__default[
|
|
1172
|
+
return ReactDomServer__default["default"].renderToStaticMarkup(uniqueTags.map(tag => React__default["default"].createElement(tag.tag || "meta", lodash.omit(tag, "tag"))));
|
|
1173
1173
|
}
|
|
1174
1174
|
|
|
1175
1175
|
addTag() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quintype/seo",
|
|
3
|
-
"version": "1.40.
|
|
3
|
+
"version": "1.40.3-update-image-schema.0",
|
|
4
4
|
"description": "SEO Modules for Quintype",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"repository": "https://github.com/quintype/quintype-node-seo",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"eslint-plugin-standard": "^5.0.0",
|
|
38
38
|
"gh-pages": "^3.2.2",
|
|
39
39
|
"husky": "^7.0.0",
|
|
40
|
-
"jsdoc": "^3.6.
|
|
40
|
+
"jsdoc": "^3.6.10",
|
|
41
41
|
"lint-staged": "^11.0.0",
|
|
42
42
|
"lodash": "^4.17.11",
|
|
43
|
-
"mocha": "^9.
|
|
43
|
+
"mocha": "^9.2.1",
|
|
44
44
|
"nyc": "^15.0.0",
|
|
45
45
|
"onchange": "^7.0.2",
|
|
46
46
|
"prettier": "^2.2.1",
|
package/src/image-tags.js
CHANGED
|
@@ -107,6 +107,7 @@ function pickImage({ pageType, config, seoConfig, data, url }) {
|
|
|
107
107
|
* @param {*} seoConfig
|
|
108
108
|
* @param {boolean} seoConfig.enableOgTags Add og tags for Facebook
|
|
109
109
|
* @param {boolean} seoConfig.enableTwitterCards Add twitter tags
|
|
110
|
+
* @param {string} seoConfig.fallbackSocialImage Optional. Should be full URL (i.e. include https://). This image will be shown in og:image and twitter:image meta tags for stories having no hero image or alternate hero/social images
|
|
110
111
|
* @param {...*} params See {@link Generator} for other Parameters
|
|
111
112
|
*/
|
|
112
113
|
export function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
getSchemaPerson,
|
|
12
12
|
getSchemaPublisher,
|
|
13
13
|
getSchemaType,
|
|
14
|
-
getSchemaWebsite
|
|
14
|
+
getSchemaWebsite
|
|
15
15
|
} from "./schema";
|
|
16
16
|
|
|
17
17
|
function getLdJsonFields(type, fields) {
|
|
@@ -37,15 +37,15 @@ function imageUrl(publisherConfig, s3Key, width, height) {
|
|
|
37
37
|
return `${imageSrc}/${s3Key}?w=${width}&h=${height}&auto=format%2Ccompress&fit=max`;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
function generateCommonData(structuredData = {}, story = {}, publisherConfig = {},
|
|
40
|
+
function generateCommonData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
|
|
41
41
|
const storyUrl = story.url || `${publisherConfig["sketches-host"]}/${story.slug}`;
|
|
42
42
|
const orgUrl = get(structuredData, ["organization", "url"], "");
|
|
43
43
|
const mainEntityUrl =
|
|
44
44
|
Object.keys(story).length > 0 && structuredData.storyUrlAsMainEntityUrl
|
|
45
45
|
? storyUrl
|
|
46
46
|
: get(structuredData, ["organization", "url"], "");
|
|
47
|
-
const imageWidth =
|
|
48
|
-
const imageHeight =
|
|
47
|
+
const imageWidth = 1200; // This value is updated based on latest google requirement
|
|
48
|
+
const imageHeight = 675; // This value is updated based on latest google requirement
|
|
49
49
|
return Object.assign(
|
|
50
50
|
{},
|
|
51
51
|
{
|
|
@@ -97,18 +97,18 @@ function articleSectionObj(story) {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
function generateArticleData(structuredData = {}, story = {}, publisherConfig = {},
|
|
100
|
+
function generateArticleData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
|
|
101
101
|
const metaKeywords = (story.seo && story.seo["meta-keywords"]) || [];
|
|
102
102
|
const authors = story.authors && story.authors.length !== 0 ? story.authors : [{ name: story["author-name"] || "" }];
|
|
103
103
|
const storyKeysPresence = Object.keys(story).length > 0;
|
|
104
|
-
const imageWidth =
|
|
105
|
-
const imageHeight =
|
|
104
|
+
const imageWidth = 1200; // This value is updated based on latest google requirement
|
|
105
|
+
const imageHeight = 675; // This value is updated based on latest google requirement
|
|
106
106
|
const storyAccessType = storyAccess(story["access"]);
|
|
107
107
|
const authorSchema = (structuredData.authorSchema && structuredData.authorSchema(story)) || [];
|
|
108
108
|
|
|
109
109
|
return Object.assign(
|
|
110
110
|
{},
|
|
111
|
-
generateCommonData(structuredData, story, publisherConfig,
|
|
111
|
+
generateCommonData(structuredData, story, publisherConfig, timezone),
|
|
112
112
|
{
|
|
113
113
|
author: authorData(authors, authorSchema, publisherConfig),
|
|
114
114
|
keywords: metaKeywords.join(","),
|
|
@@ -117,17 +117,17 @@ function generateArticleData(structuredData = {}, story = {}, publisherConfig =
|
|
|
117
117
|
dateCreated: stripMillisecondsFromTime(new Date(story["first-published-at"]), timezone),
|
|
118
118
|
dateModified: stripMillisecondsFromTime(new Date(story["last-published-at"]), timezone),
|
|
119
119
|
name: (storyKeysPresence && story.headline) || "",
|
|
120
|
-
image: generateArticleImageData(story["hero-image-s3-key"], publisherConfig
|
|
120
|
+
image: generateArticleImageData(story["hero-image-s3-key"], publisherConfig),
|
|
121
121
|
isAccessibleForFree: storyAccessType,
|
|
122
|
-
isPartOf: generateIsPartOfDataForArticle(story, publisherConfig
|
|
122
|
+
isPartOf: generateIsPartOfDataForArticle(story, publisherConfig),
|
|
123
123
|
},
|
|
124
124
|
articleSectionObj(story)
|
|
125
125
|
);
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
function generateArticleImageData(image, publisherConfig = {}
|
|
129
|
-
const imageWidth =
|
|
130
|
-
const imageHeight =
|
|
128
|
+
function generateArticleImageData(image, publisherConfig = {}) {
|
|
129
|
+
const imageWidth = 1200; // This value is updated based on latest google requirement
|
|
130
|
+
const imageHeight = 675; // This value is updated based on latest google requirement
|
|
131
131
|
const articleImage = imageUrl(publisherConfig, image, imageWidth, imageHeight);
|
|
132
132
|
|
|
133
133
|
return Object.assign(
|
|
@@ -148,13 +148,13 @@ function storyAccess(access) {
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
function generateIsPartOfDataForArticle(story = {}, publisherConfig = {}
|
|
151
|
+
function generateIsPartOfDataForArticle(story = {}, publisherConfig = {}) {
|
|
152
152
|
return Object.assign(
|
|
153
153
|
{},
|
|
154
154
|
{
|
|
155
155
|
"@type": "WebPage",
|
|
156
156
|
url: `${publisherConfig["sketches-host"]}/${story.slug}`,
|
|
157
|
-
primaryImageOfPage: generateArticleImageData(story["hero-image-s3-key"], publisherConfig
|
|
157
|
+
primaryImageOfPage: generateArticleImageData(story["hero-image-s3-key"], publisherConfig),
|
|
158
158
|
}
|
|
159
159
|
);
|
|
160
160
|
}
|
|
@@ -164,7 +164,7 @@ function generateIsPartOfDataForNewsArticle(story = {}, publisherConfig = {}, pa
|
|
|
164
164
|
const productId = `${publisherConfig["publisher-name"]}${
|
|
165
165
|
structuredData.isShowcaseProduct ? ".com:showcase" : ".com:basic"
|
|
166
166
|
}`;
|
|
167
|
-
const isPartOfData = generateIsPartOfDataForArticle(story, publisherConfig
|
|
167
|
+
const isPartOfData = generateIsPartOfDataForArticle(story, publisherConfig);
|
|
168
168
|
|
|
169
169
|
if (structuredData.isSubscriptionsEnabled) {
|
|
170
170
|
return Object.assign(isPartOfData, {
|
|
@@ -182,7 +182,7 @@ function generateIsPartOfDataForNewsArticle(story = {}, publisherConfig = {}, pa
|
|
|
182
182
|
name: publisherName,
|
|
183
183
|
productID: productId,
|
|
184
184
|
url: `${publisherConfig["sketches-host"]}/${story.slug}`,
|
|
185
|
-
primaryImageOfPage: generateArticleImageData(story["hero-image-s3-key"], publisherConfig
|
|
185
|
+
primaryImageOfPage: generateArticleImageData(story["hero-image-s3-key"], publisherConfig),
|
|
186
186
|
}
|
|
187
187
|
);
|
|
188
188
|
}
|
|
@@ -224,9 +224,9 @@ function findStoryElementField(card, type, field, defaultValue) {
|
|
|
224
224
|
else return defaultValue;
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherConfig = {},
|
|
228
|
-
const imageWidth =
|
|
229
|
-
const imageHeight =
|
|
227
|
+
function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
|
|
228
|
+
const imageWidth = 1200; // This value is updated based on latest google requirement
|
|
229
|
+
const imageHeight = 675; // This value is updated based on latest google requirement
|
|
230
230
|
const authorSchema = (structuredData.authorSchema && structuredData.authorSchema(story)) || [];
|
|
231
231
|
return {
|
|
232
232
|
headline: story.headline,
|
|
@@ -254,18 +254,17 @@ function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherC
|
|
|
254
254
|
};
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
-
function generateVideoArticleData(structuredData = {}, story = {}, publisherConfig = {},
|
|
257
|
+
function generateVideoArticleData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
|
|
258
258
|
const metaKeywords = (story.seo && story.seo["meta-keywords"]) || [];
|
|
259
|
-
const articleSection = get(story, ["sections", "0", "display-name"], "");
|
|
260
259
|
const embedUrl = get(story, ["cards", "0", "story-elements", "0", "embed-url"], "");
|
|
261
260
|
const socialShareMsg = get(story, ["summary"], "");
|
|
262
261
|
const metaDescription = get(story, ["seo", "meta-description"], "");
|
|
263
262
|
const subHeadline = get(story, ["subheadline"], "");
|
|
264
263
|
const headline = get(story, ["headline"], "");
|
|
265
|
-
const imageWidth =
|
|
266
|
-
const imageHeight =
|
|
264
|
+
const imageWidth = 1200; // This value is updated based on latest google requirement
|
|
265
|
+
const imageHeight = 675; // This value is updated based on latest google requirement
|
|
267
266
|
const authorSchema = (structuredData.authorSchema && structuredData.authorSchema(story)) || [];
|
|
268
|
-
return Object.assign({}, generateCommonData(structuredData, story, publisherConfig,
|
|
267
|
+
return Object.assign({}, generateCommonData(structuredData, story, publisherConfig, timezone), {
|
|
269
268
|
author: authorData(story.authors, authorSchema, publisherConfig),
|
|
270
269
|
keywords: metaKeywords.join(","),
|
|
271
270
|
dateCreated: stripMillisecondsFromTime(new Date(story["first-published-at"]), timezone),
|
|
@@ -412,7 +411,7 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re
|
|
|
412
411
|
let articleData = {};
|
|
413
412
|
|
|
414
413
|
if (!isStructuredDataEmpty) {
|
|
415
|
-
articleData = generateArticleData(structuredData, story, publisherConfig,
|
|
414
|
+
articleData = generateArticleData(structuredData, story, publisherConfig, timezone);
|
|
416
415
|
structuredDataTags.map((type) => {
|
|
417
416
|
if (pageType === type) {
|
|
418
417
|
tags.push(ldJson("Organization", structuredData.organization));
|
|
@@ -472,14 +471,14 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re
|
|
|
472
471
|
if (structuredData.enableLiveBlog && story["story-template"] === "live-blog") {
|
|
473
472
|
return ldJson(
|
|
474
473
|
"LiveBlogPosting",
|
|
475
|
-
Object.assign({}, generateLiveBlogPostingData(structuredData, story, publisherConfig,
|
|
474
|
+
Object.assign({}, generateLiveBlogPostingData(structuredData, story, publisherConfig, timezone))
|
|
476
475
|
);
|
|
477
476
|
}
|
|
478
477
|
|
|
479
478
|
if (structuredData.enableVideo && story["story-template"] === "video") {
|
|
480
479
|
return ldJson(
|
|
481
480
|
"VideoObject",
|
|
482
|
-
generateVideoArticleData(structuredData, story, publisherConfig,
|
|
481
|
+
generateVideoArticleData(structuredData, story, publisherConfig, timezone)
|
|
483
482
|
);
|
|
484
483
|
}
|
|
485
484
|
|