@quintype/seo 1.40.6-embed-url.0 → 1.40.6-embed-url.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
@@ -820,23 +820,19 @@ function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherC
820
820
  };
821
821
  }
822
822
 
823
- function getEmbedUrl({ cards }) {
824
- for (let i = 0; i < cards.length; i++) {
825
- const storyElements = cards[i]["story-elements"];
826
- for (let j = 0; j < storyElements.length; j++) {
827
- const storyElement = storyElements[j];
828
- if (storyElement["embed-url"]) {
829
- return storyElement["embed-url"];
830
- }
831
- }
823
+ function getEmbedUrl(cards) {
824
+ // get the first story element which has the embed url
825
+ const storyElement = cards.flatMap(card => card["story-elements"]).find(elem => elem["embed-url"]);
826
+ if (storyElement) {
827
+ return storyElement["embed-url"];
832
828
  }
833
-
834
- return '';
829
+ return "";
835
830
  }
836
831
 
837
832
  function generateVideoArticleData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
838
833
  const metaKeywords = story.seo && story.seo["meta-keywords"] || [];
839
- const embedUrl = getEmbedUrl(story);
834
+ const storyCards = get__default["default"](story, ["cards"], []);
835
+ const embedUrl = getEmbedUrl(storyCards);
840
836
  const socialShareMsg = get__default["default"](story, ["summary"], "");
841
837
  const metaDescription = get__default["default"](story, ["seo", "meta-description"], "");
842
838
  const subHeadline = get__default["default"](story, ["subheadline"], "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/seo",
3
- "version": "1.40.6-embed-url.0",
3
+ "version": "1.40.6-embed-url.1",
4
4
  "description": "SEO Modules for Quintype",
5
5
  "main": "dist/index.cjs.js",
6
6
  "repository": "https://github.com/quintype/quintype-node-seo",
@@ -254,24 +254,22 @@ function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherC
254
254
  };
255
255
  }
256
256
 
257
- function getEmbedUrl({cards}) {
258
- for (let i = 0; i < cards.length; i++) {
259
- const storyElements = cards[i]["story-elements"];
260
- for (let j = 0; j < storyElements.length; j++) {
261
- const storyElement = storyElements[j];
262
- if (storyElement["embed-url"]) {
263
- return storyElement["embed-url"]
264
- }
265
- }
266
-
257
+ function getEmbedUrl(cards) {
258
+ // get the first story element which has the embed url
259
+ const storyElement = cards
260
+ .flatMap((card) => card["story-elements"])
261
+ .find((elem) => elem["embed-url"]);
262
+ if (storyElement) {
263
+ return storyElement["embed-url"];
267
264
  }
268
-
269
- return ''
265
+ return "";
270
266
  }
271
267
 
268
+
272
269
  function generateVideoArticleData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
273
270
  const metaKeywords = (story.seo && story.seo["meta-keywords"]) || [];
274
- const embedUrl = getEmbedUrl(story)
271
+ const storyCards = get(story, ["cards"], []);
272
+ const embedUrl = getEmbedUrl(storyCards);
275
273
  const socialShareMsg = get(story, ["summary"], "");
276
274
  const metaDescription = get(story, ["seo", "meta-description"], "");
277
275
  const subHeadline = get(story, ["subheadline"], "");
@@ -491,10 +489,7 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re
491
489
  }
492
490
 
493
491
  if (structuredData.enableVideo && story["story-template"] === "video") {
494
- return ldJson(
495
- "VideoObject",
496
- generateVideoArticleData(structuredData, story, publisherConfig, timezone)
497
- );
492
+ return ldJson("VideoObject", generateVideoArticleData(structuredData, story, publisherConfig, timezone));
498
493
  }
499
494
 
500
495
  if (structuredData.enableNewsArticle !== "withoutArticleSchema") {