@quintype/seo 1.40.6-embed-url.1 → 1.40.6-embed-url.4

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,8 +3,8 @@
3
3
  "editor.defaultFormatter": "esbenp.prettier-vscode"
4
4
  },
5
5
  "editor.tabSize": 2,
6
- "editor.formatOnSave": true,
7
6
  "editor.detectIndentation": false,
7
+ "editor.formatOnSave": true,
8
8
  "files.insertFinalNewline": true,
9
9
  "files.trimTrailingWhitespace": true,
10
10
  "editor.codeActionsOnSave": {
package/dist/index.cjs.js CHANGED
@@ -821,12 +821,23 @@ function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherC
821
821
  }
822
822
 
823
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"];
828
- }
829
- return "";
824
+ let embedUrl = "";
825
+
826
+ // not using the return value of top level find
827
+ // coz we only need the embed url
828
+ // find is used for early exit
829
+ cards.find(card => {
830
+ const storyElements = card["story-elements"];
831
+ return storyElements.find((elem, index) => {
832
+ if (elem["embed-url"]) {
833
+ embedUrl = elem["embed-url"];
834
+ return true;
835
+ }
836
+ return false;
837
+ });
838
+ });
839
+
840
+ return embedUrl;
830
841
  }
831
842
 
832
843
  function generateVideoArticleData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/seo",
3
- "version": "1.40.6-embed-url.1",
3
+ "version": "1.40.6-embed-url.4",
4
4
  "description": "SEO Modules for Quintype",
5
5
  "main": "dist/index.cjs.js",
6
6
  "repository": "https://github.com/quintype/quintype-node-seo",
@@ -255,14 +255,23 @@ function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherC
255
255
  }
256
256
 
257
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"];
264
- }
265
- return "";
258
+ let embedUrl = "";
259
+
260
+ // not using the return value of top level find
261
+ // coz we only need the embed url
262
+ // find is used for early exit
263
+ cards.find((card) => {
264
+ const storyElements = card["story-elements"];
265
+ return storyElements.find((elem, index) => {
266
+ if (elem["embed-url"]) {
267
+ embedUrl = elem["embed-url"];
268
+ return true;
269
+ }
270
+ return false;
271
+ });
272
+ });
273
+
274
+ return embedUrl;
266
275
  }
267
276
 
268
277