@quintype/seo 1.40.6-embed-url.0 → 1.40.6-embed-url.3

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.
@@ -3,7 +3,6 @@
3
3
  "editor.defaultFormatter": "esbenp.prettier-vscode"
4
4
  },
5
5
  "editor.tabSize": 2,
6
- "editor.formatOnSave": true,
7
6
  "editor.detectIndentation": false,
8
7
  "files.insertFinalNewline": true,
9
8
  "files.trimTrailingWhitespace": true,
package/dist/index.cjs.js CHANGED
@@ -820,23 +820,32 @@ 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"];
823
+ function getEmbedUrl(cards) {
824
+ // get the first story element which has the embed url
825
+
826
+ let storyElemIndex;
827
+
828
+ const card = cards.find(card => {
829
+ const storyElements = card["story-elements"];
830
+ return storyElements.find((elem, index) => {
831
+ if (elem["embed-url"]) {
832
+ storyElemIndex = index;
833
+ return elem["embed-url"];
830
834
  }
831
- }
835
+ return false;
836
+ });
837
+ });
838
+ if (card) {
839
+ const storyElement = card['story-elements'][storyElemIndex];
840
+ return storyElement["embed-url"];
832
841
  }
833
-
834
- return '';
842
+ return "";
835
843
  }
836
844
 
837
845
  function generateVideoArticleData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
838
846
  const metaKeywords = story.seo && story.seo["meta-keywords"] || [];
839
- const embedUrl = getEmbedUrl(story);
847
+ const storyCards = get__default["default"](story, ["cards"], []);
848
+ const embedUrl = getEmbedUrl(storyCards);
840
849
  const socialShareMsg = get__default["default"](story, ["summary"], "");
841
850
  const metaDescription = get__default["default"](story, ["seo", "meta-description"], "");
842
851
  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.3",
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,33 @@ 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
- }
257
+ function getEmbedUrl(cards) {
258
+ // get the first story element which has the embed url
266
259
 
267
- }
260
+ let storyElemIndex;
268
261
 
269
- return ''
262
+ const card = cards.find((card) => {
263
+ const storyElements = card["story-elements"];
264
+ return storyElements.find((elem, index) => {
265
+ if (elem["embed-url"]) {
266
+ storyElemIndex = index;
267
+ return elem["embed-url"];
268
+ }
269
+ return false;
270
+ });
271
+ });
272
+ if (card) {
273
+ const storyElement = card['story-elements'][storyElemIndex]
274
+ return storyElement["embed-url"];
275
+ }
276
+ return "";
270
277
  }
271
278
 
279
+
272
280
  function generateVideoArticleData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
273
281
  const metaKeywords = (story.seo && story.seo["meta-keywords"]) || [];
274
- const embedUrl = getEmbedUrl(story)
282
+ const storyCards = get(story, ["cards"], []);
283
+ const embedUrl = getEmbedUrl(storyCards);
275
284
  const socialShareMsg = get(story, ["summary"], "");
276
285
  const metaDescription = get(story, ["seo", "meta-description"], "");
277
286
  const subHeadline = get(story, ["subheadline"], "");
@@ -491,10 +500,7 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re
491
500
  }
492
501
 
493
502
  if (structuredData.enableVideo && story["story-template"] === "video") {
494
- return ldJson(
495
- "VideoObject",
496
- generateVideoArticleData(structuredData, story, publisherConfig, timezone)
497
- );
503
+ return ldJson("VideoObject", generateVideoArticleData(structuredData, story, publisherConfig, timezone));
498
504
  }
499
505
 
500
506
  if (structuredData.enableNewsArticle !== "withoutArticleSchema") {