@quintype/seo 1.40.7-amphtml-issue.0 → 1.40.8

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/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.40.8](https://github.com/quintype/quintype-node-seo/compare/v1.40.5...v1.40.8) (2022-07-11)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * Amphtml error ([#526](https://github.com/quintype/quintype-node-seo/issues/526)) ([24b6c61](https://github.com/quintype/quintype-node-seo/commit/24b6c616118f3db1a2cdda0d98d2827bf2a0d099))
11
+ * **video-structured-data:** use correct embed url ([#528](https://github.com/quintype/quintype-node-seo/issues/528)) ([abe449f](https://github.com/quintype/quintype-node-seo/commit/abe449fd7e75d45f9b9896444f3ef644ca2cf497))
12
+
13
+ ### [1.40.7](https://github.com/quintype/quintype-node-seo/compare/v1.40.6...v1.40.7) (2022-07-11)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * Amphtml error ([#526](https://github.com/quintype/quintype-node-seo/issues/526)) ([24b6c61](https://github.com/quintype/quintype-node-seo/commit/24b6c616118f3db1a2cdda0d98d2827bf2a0d099))
19
+
20
+ ### [1.40.6](https://github.com/quintype/quintype-node-seo/compare/v1.40.5...v1.40.6) (2022-07-11)
21
+
22
+ ### [1.40.5](https://github.com/quintype/quintype-node-seo/compare/v1.40.1...v1.40.5) (2022-06-30)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * og image for stories with no image | fallback og image ([454aef9](https://github.com/quintype/quintype-node-seo/commit/454aef9e0a1bc5acfde1aa56d223c518255376a2))
28
+ * Update image schema ([#522](https://github.com/quintype/quintype-node-seo/issues/522)) ([5e42cdc](https://github.com/quintype/quintype-node-seo/commit/5e42cdcbb14d587251b7a3f932a4f98dd358f188))
29
+
5
30
  ### [1.40.4](https://github.com/quintype/quintype-node-seo/compare/v1.40.4-amptag.0...v1.40.4) (2022-03-22)
6
31
 
7
32
  ### [1.40.3](https://github.com/quintype/quintype-node-seo/compare/v1.40.2...v1.40.3) (2022-02-23)
package/dist/index.cjs.js CHANGED
@@ -159,6 +159,33 @@ function buildCustomTags(customTags = {}, pageType = "") {
159
159
  return {};
160
160
  }
161
161
 
162
+ function buildTagsFromStaticPage(config, page, url = {}, data) {
163
+ const seoData = lodash.get(page, ["metadata", "seo"], {});
164
+ const customSeo = lodash.get(data, ["data", "customSeo"], {});
165
+ if (lodash.isEmpty(seoData) && lodash.isEmpty(customSeo)) return;
166
+
167
+ const { "meta-title": metaTitle, "meta-description": metaDescription, "meta-keywords": keywords } = seoData;
168
+
169
+ const title = customSeo.title || metaTitle || page.title;
170
+ const pageTitle = customSeo["page-title"] || title;
171
+ const description = customSeo.description || metaDescription;
172
+ const ogTitle = customSeo.ogTitle || title;
173
+ const staticPageUrl = `${config["sketches-host"]}${url.pathname}`;
174
+ const ogDescription = customSeo.ogDescription || description;
175
+
176
+ return {
177
+ title,
178
+ "page-title": pageTitle,
179
+ description,
180
+ keywords: `${title},${config["publisher-name"]}`,
181
+ canonicalUrl: staticPageUrl,
182
+ ogUrl: staticPageUrl,
183
+ ogTitle,
184
+ ogDescription,
185
+ keywords: customSeo.keywords || keywords
186
+ };
187
+ }
188
+
162
189
  // The findRelevantConfig method call has no ownerId for home page.
163
190
  // This causes the seoMetadata to be undefined.
164
191
  // So the default value for the ownerId is set to null.
@@ -215,6 +242,8 @@ function getSeoData(config, pageType, data, url = {}, seoConfig = {}) {
215
242
  return buildTagsFromStory(config, lodash.get(data, ["data", "story"]), url, data) || getSeoData(config, "home-page", data, url);
216
243
  case "author-page":
217
244
  return buildTagsFromAuthor(config, lodash.get(data, ["data", "author"], {}), url, data) || getSeoData(config, "home-page", data, url);
245
+ case "static-page":
246
+ return buildTagsFromStaticPage(config, lodash.get(data, ["data", "page"], {}), url, data) || getSeoData(config, "home-page", data, url);
218
247
  case "shell":
219
248
  return getShellSeoData(config);
220
249
  default:
@@ -467,7 +496,8 @@ function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
467
496
  content: includesHost ? image : `https://${config["cdn-image"]}/${image.path([16, 9], {
468
497
  w: 1200,
469
498
  auto: "format,compress",
470
- ogImage: true
499
+ ogImage: true,
500
+ enlarge: true
471
501
  })}`
472
502
  });
473
503
  alt && tags.push({ property: "twitter:image:alt", content: alt });
@@ -479,7 +509,8 @@ function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
479
509
  content: includesHost ? image : `https://${config["cdn-image"]}/${image.path([40, 21], {
480
510
  w: 1200,
481
511
  auto: "format,compress",
482
- ogImage: true
512
+ ogImage: true,
513
+ enlarge: true
483
514
  })}`
484
515
  });
485
516
  tags.push({ property: "og:image:width", content: 1200 });
@@ -791,9 +822,30 @@ function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherC
791
822
  };
792
823
  }
793
824
 
825
+ function getEmbedUrl(cards) {
826
+ let embedUrl = "";
827
+
828
+ // not using the return value of top level find
829
+ // coz we only need the embed url
830
+ // find is used for early exit
831
+ cards.find(card => {
832
+ const storyElements = card["story-elements"];
833
+ return storyElements.find((elem, index) => {
834
+ if (elem["embed-url"]) {
835
+ embedUrl = elem["embed-url"];
836
+ return true;
837
+ }
838
+ return false;
839
+ });
840
+ });
841
+
842
+ return embedUrl;
843
+ }
844
+
794
845
  function generateVideoArticleData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
795
846
  const metaKeywords = story.seo && story.seo["meta-keywords"] || [];
796
- const embedUrl = get__default["default"](story, ["cards", "0", "story-elements", "0", "embed-url"], "");
847
+ const storyCards = get__default["default"](story, ["cards"], []);
848
+ const embedUrl = getEmbedUrl(storyCards);
797
849
  const socialShareMsg = get__default["default"](story, ["summary"], "");
798
850
  const metaDescription = get__default["default"](story, ["seo", "meta-description"], "");
799
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.7-amphtml-issue.0",
3
+ "version": "1.40.8",
4
4
  "description": "SEO Modules for Quintype",
5
5
  "main": "dist/index.cjs.js",
6
6
  "repository": "https://github.com/quintype/quintype-node-seo",
package/src/image-tags.js CHANGED
@@ -128,6 +128,7 @@ export function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
128
128
  w: 1200,
129
129
  auto: "format,compress",
130
130
  ogImage: true,
131
+ enlarge: true,
131
132
  })}`,
132
133
  });
133
134
  alt && tags.push({ property: "twitter:image:alt", content: alt });
@@ -142,6 +143,7 @@ export function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
142
143
  w: 1200,
143
144
  auto: "format,compress",
144
145
  ogImage: true,
146
+ enlarge: true,
145
147
  })}`,
146
148
  });
147
149
  tags.push({ property: "og:image:width", content: 1200 });
@@ -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) {
@@ -254,9 +254,30 @@ function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherC
254
254
  };
255
255
  }
256
256
 
257
+ function getEmbedUrl(cards) {
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;
275
+ }
276
+
257
277
  function generateVideoArticleData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
258
278
  const metaKeywords = (story.seo && story.seo["meta-keywords"]) || [];
259
- const embedUrl = get(story, ["cards", "0", "story-elements", "0", "embed-url"], "");
279
+ const storyCards = get(story, ["cards"], []);
280
+ const embedUrl = getEmbedUrl(storyCards);
260
281
  const socialShareMsg = get(story, ["summary"], "");
261
282
  const metaDescription = get(story, ["seo", "meta-description"], "");
262
283
  const subHeadline = get(story, ["subheadline"], "");
@@ -476,10 +497,7 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re
476
497
  }
477
498
 
478
499
  if (structuredData.enableVideo && story["story-template"] === "video") {
479
- return ldJson(
480
- "VideoObject",
481
- generateVideoArticleData(structuredData, story, publisherConfig, timezone)
482
- );
500
+ return ldJson("VideoObject", generateVideoArticleData(structuredData, story, publisherConfig, timezone));
483
501
  }
484
502
 
485
503
  if (structuredData.enableNewsArticle !== "withoutArticleSchema") {
package/src/text-tags.js CHANGED
@@ -112,6 +112,33 @@ function buildCustomTags(customTags = {}, pageType = "") {
112
112
  return {};
113
113
  }
114
114
 
115
+ function buildTagsFromStaticPage(config, page, url = {}, data) {
116
+ const seoData = get(page, ["metadata", "seo"], {});
117
+ const customSeo = get(data, ["data", "customSeo"], {});
118
+ if (isEmpty(seoData) && isEmpty(customSeo)) return;
119
+
120
+ const { "meta-title": metaTitle, "meta-description": metaDescription, "meta-keywords": keywords } = seoData;
121
+
122
+ const title = customSeo.title || metaTitle || page.title;
123
+ const pageTitle = customSeo["page-title"] || title;
124
+ const description = customSeo.description || metaDescription;
125
+ const ogTitle = customSeo.ogTitle || title;
126
+ const staticPageUrl = `${config["sketches-host"]}${url.pathname}`;
127
+ const ogDescription = customSeo.ogDescription || description;
128
+
129
+ return {
130
+ title,
131
+ "page-title": pageTitle,
132
+ description,
133
+ keywords: `${title},${config["publisher-name"]}`,
134
+ canonicalUrl: staticPageUrl,
135
+ ogUrl: staticPageUrl,
136
+ ogTitle,
137
+ ogDescription,
138
+ keywords: customSeo.keywords || keywords,
139
+ };
140
+ }
141
+
115
142
  // The findRelevantConfig method call has no ownerId for home page.
116
143
  // This causes the seoMetadata to be undefined.
117
144
  // So the default value for the ownerId is set to null.
@@ -188,6 +215,11 @@ function getSeoData(config, pageType, data, url = {}, seoConfig = {}) {
188
215
  buildTagsFromAuthor(config, get(data, ["data", "author"], {}), url, data) ||
189
216
  getSeoData(config, "home-page", data, url)
190
217
  );
218
+ case "static-page":
219
+ return (
220
+ buildTagsFromStaticPage(config, get(data, ["data", "page"], {}), url, data) ||
221
+ getSeoData(config, "home-page", data, url)
222
+ );
191
223
  case "shell":
192
224
  return getShellSeoData(config);
193
225
  default:
@@ -3,18 +3,18 @@ const { getSeoMetadata, assertContains } = require("./utils");
3
3
 
4
4
  const assert = require("assert");
5
5
 
6
- describe("ImageTags", function() {
6
+ describe("ImageTags", function () {
7
7
  const seoConfig = {
8
8
  generators: [ImageTags],
9
9
  enableOgTags: true,
10
- enableTwitterCards: true
10
+ enableTwitterCards: true,
11
11
  };
12
12
 
13
13
  const config = {
14
- "cdn-image": "thumbor.assettype.com"
14
+ "cdn-image": "thumbor.assettype.com",
15
15
  };
16
16
 
17
- it("gets the twitter tags", function() {
17
+ it("gets the twitter tags", function () {
18
18
  const story = {
19
19
  "hero-image-s3-key": "my/image.png",
20
20
  alternative: {
@@ -22,51 +22,39 @@ describe("ImageTags", function() {
22
22
  default: {
23
23
  headline: null,
24
24
  "hero-image": {
25
- "hero-image-s3-key": "my/socialimage.png"
26
- }
27
- }
25
+ "hero-image-s3-key": "my/socialimage.png",
26
+ },
27
+ },
28
28
  },
29
29
  home: {
30
30
  default: {
31
31
  headline: null,
32
32
  "hero-image": {
33
- "hero-image-s3-key": "my/homeimage.png"
34
- }
35
- }
36
- }
37
- }
33
+ "hero-image-s3-key": "my/homeimage.png",
34
+ },
35
+ },
36
+ },
37
+ },
38
38
  };
39
- const string = getSeoMetadata(
40
- seoConfig,
41
- config,
42
- "story-page",
43
- { data: { story: story } },
44
- {}
45
- );
46
- const ampPageString = getSeoMetadata(
47
- seoConfig,
48
- config,
49
- "story-page-amp",
50
- { data: { story: story } },
51
- {}
52
- );
39
+ const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, {});
40
+ const ampPageString = getSeoMetadata(seoConfig, config, "story-page-amp", { data: { story: story } }, {});
53
41
  assertContains(
54
- '<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?w=1200&amp;auto=format%2Ccompress&amp;ogImage=true"/>',
42
+ '<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?w=1200&amp;auto=format%2Ccompress&amp;ogImage=true&amp;enlarge=true"/>',
55
43
  string
56
44
  );
57
45
  assertContains(
58
- '<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?w=1200&amp;auto=format%2Ccompress&amp;ogImage=true"/>',
46
+ '<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?w=1200&amp;auto=format%2Ccompress&amp;ogImage=true&amp;enlarge=true"/>',
59
47
  ampPageString
60
48
  );
61
49
  });
62
50
 
63
- it("has facebook tags resized correctly", function() {
51
+ it("has facebook tags resized correctly", function () {
64
52
  const story = {
65
53
  "hero-image-s3-key": "my/images.png",
66
54
  "hero-image-metadata": {
67
55
  width: 2400,
68
56
  height: 1260,
69
- "focus-point": [0, 0]
57
+ "focus-point": [0, 0],
70
58
  },
71
59
  alternative: {
72
60
  social: {
@@ -76,11 +64,11 @@ describe("ImageTags", function() {
76
64
  "hero-image-metadata": {
77
65
  width: 2400,
78
66
  height: 1260,
79
- "focus-point": [0, 0]
67
+ "focus-point": [0, 0],
80
68
  },
81
- "hero-image-s3-key": "my/socialimage.png"
82
- }
83
- }
69
+ "hero-image-s3-key": "my/socialimage.png",
70
+ },
71
+ },
84
72
  },
85
73
  home: {
86
74
  default: {
@@ -89,34 +77,22 @@ describe("ImageTags", function() {
89
77
  "hero-image-metadata": {
90
78
  width: 2400,
91
79
  height: 1260,
92
- "focus-point": [0, 0]
80
+ "focus-point": [0, 0],
93
81
  },
94
- "hero-image-s3-key": "my/homeimage.png"
95
- }
96
- }
97
- }
98
- }
82
+ "hero-image-s3-key": "my/homeimage.png",
83
+ },
84
+ },
85
+ },
86
+ },
99
87
  };
100
- const string = getSeoMetadata(
101
- seoConfig,
102
- config,
103
- "story-page",
104
- { data: { story: story } },
105
- {}
106
- );
107
- const ampPageString = getSeoMetadata(
108
- seoConfig,
109
- config,
110
- "story-page-amp",
111
- { data: { story: story } },
112
- {}
113
- );
88
+ const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, {});
89
+ const ampPageString = getSeoMetadata(seoConfig, config, "story-page-amp", { data: { story: story } }, {});
114
90
  assertContains(
115
- '<meta property="og:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?rect=0%2C0%2C2400%2C1260&amp;w=1200&amp;auto=format%2Ccompress&amp;ogImage=true"/>',
91
+ '<meta property="og:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?rect=0%2C0%2C2400%2C1260&amp;w=1200&amp;auto=format%2Ccompress&amp;ogImage=true&amp;enlarge=true"/>',
116
92
  string
117
93
  );
118
94
  assertContains(
119
- '<meta property="og:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?rect=0%2C0%2C2400%2C1260&amp;w=1200&amp;auto=format%2Ccompress&amp;ogImage=true"/>',
95
+ '<meta property="og:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?rect=0%2C0%2C2400%2C1260&amp;w=1200&amp;auto=format%2Ccompress&amp;ogImage=true&amp;enlarge=true"/>',
120
96
  ampPageString
121
97
  );
122
98
  assertContains('<meta property="og:image:width" content="1200"/>', string);
@@ -125,7 +101,7 @@ describe("ImageTags", function() {
125
101
  assertContains('<meta property="og:image:height" content="630"/>', ampPageString);
126
102
  });
127
103
 
128
- it("gets card image values instead of story image values on card share", function() {
104
+ it("gets card image values instead of story image values on card share", function () {
129
105
  const story = {
130
106
  "hero-image-s3-key": "my/image.png",
131
107
  cards: [
@@ -140,38 +116,32 @@ describe("ImageTags", function() {
140
116
  metadata: {
141
117
  width: 1300,
142
118
  height: 1065,
143
- "mime-type": "image/jpeg"
144
- }
145
- }
146
- }
147
- }
148
- }
149
- ]
119
+ "mime-type": "image/jpeg",
120
+ },
121
+ },
122
+ },
123
+ },
124
+ },
125
+ ],
150
126
  };
151
127
 
152
128
  const opts = {
153
129
  url: {
154
130
  query: {
155
- cardId: "sample-card-id"
156
- }
157
- }
131
+ cardId: "sample-card-id",
132
+ },
133
+ },
158
134
  };
159
135
 
160
- const string = getSeoMetadata(
161
- seoConfig,
162
- config,
163
- "story-page",
164
- { data: { story: story } },
165
- opts
166
- );
136
+ const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, opts);
167
137
 
168
138
  assertContains(
169
- '<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fcard%2Fimage.jpg?w=1200&amp;auto=format%2Ccompress&amp;ogImage=true"/>',
139
+ '<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fcard%2Fimage.jpg?w=1200&amp;auto=format%2Ccompress&amp;ogImage=true&amp;enlarge=true"/>',
170
140
  string
171
141
  );
172
142
  });
173
143
 
174
- it("gets story hero image attribution values instead of card attribution values on story share", function() {
144
+ it("gets story hero image attribution values instead of card attribution values on story share", function () {
175
145
  const story = {
176
146
  "hero-image-s3-key": "my/image.png",
177
147
  "hero-image-attribution": "attribution test",
@@ -188,32 +158,25 @@ describe("ImageTags", function() {
188
158
  metadata: {
189
159
  width: 1300,
190
160
  height: 1065,
191
- "mime-type": "image/jpeg"
192
- }
193
- }
194
- }
195
- }
196
- }
197
- ]
161
+ "mime-type": "image/jpeg",
162
+ },
163
+ },
164
+ },
165
+ },
166
+ },
167
+ ],
198
168
  };
199
169
 
200
170
  const opts = {};
201
171
 
202
- const string = getSeoMetadata(
203
- seoConfig,
204
- config,
205
- "story-page",
206
- { data: { story: story } },
207
- opts
208
- );
209
-
210
- assertContains('<meta property="twitter:image:alt" content="attribution test"/>', string)
172
+ const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, opts);
211
173
 
212
- assertContains('<meta property="og:image:alt" content="attribution test"/>', string)
174
+ assertContains('<meta property="twitter:image:alt" content="attribution test"/>', string);
213
175
 
176
+ assertContains('<meta property="og:image:alt" content="attribution test"/>', string);
214
177
  });
215
178
 
216
- it("gets story summary as attribution if hero image attribution is not present", function() {
179
+ it("gets story summary as attribution if hero image attribution is not present", function () {
217
180
  const story = {
218
181
  "hero-image-s3-key": "my/image.png",
219
182
  "hero-image-attribution": null,
@@ -230,32 +193,25 @@ describe("ImageTags", function() {
230
193
  metadata: {
231
194
  width: 1300,
232
195
  height: 1065,
233
- "mime-type": "image/jpeg"
234
- }
235
- }
236
- }
237
- }
238
- }
239
- ]
196
+ "mime-type": "image/jpeg",
197
+ },
198
+ },
199
+ },
200
+ },
201
+ },
202
+ ],
240
203
  };
241
204
 
242
205
  const opts = {};
243
206
 
244
- const string = getSeoMetadata(
245
- seoConfig,
246
- config,
247
- "story-page",
248
- { data: { story: story } },
249
- opts
250
- );
251
-
252
- assertContains('<meta property="twitter:image:alt" content="attribution test"/>', string)
207
+ const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, opts);
253
208
 
254
- assertContains('<meta property="og:image:alt" content="attribution test"/>', string)
209
+ assertContains('<meta property="twitter:image:alt" content="attribution test"/>', string);
255
210
 
211
+ assertContains('<meta property="og:image:alt" content="attribution test"/>', string);
256
212
  });
257
213
 
258
- it("gets story headline as attribution if hero image attribution and summary is not present", function() {
214
+ it("gets story headline as attribution if hero image attribution and summary is not present", function () {
259
215
  const story = {
260
216
  "hero-image-s3-key": "my/image.png",
261
217
  "hero-image-attribution": null,
@@ -273,32 +229,25 @@ describe("ImageTags", function() {
273
229
  metadata: {
274
230
  width: 1300,
275
231
  height: 1065,
276
- "mime-type": "image/jpeg"
277
- }
278
- }
279
- }
280
- }
281
- }
282
- ]
232
+ "mime-type": "image/jpeg",
233
+ },
234
+ },
235
+ },
236
+ },
237
+ },
238
+ ],
283
239
  };
284
240
 
285
241
  const opts = {};
286
242
 
287
- const string = getSeoMetadata(
288
- seoConfig,
289
- config,
290
- "story-page",
291
- { data: { story: story } },
292
- opts
293
- );
294
-
295
- assertContains('<meta property="twitter:image:alt" content="attribution test"/>', string)
243
+ const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, opts);
296
244
 
297
- assertContains('<meta property="og:image:alt" content="attribution test"/>', string)
245
+ assertContains('<meta property="twitter:image:alt" content="attribution test"/>', string);
298
246
 
247
+ assertContains('<meta property="og:image:alt" content="attribution test"/>', string);
299
248
  });
300
249
 
301
- it("gets card image attribution values instead of story attribution values on card share", function() {
250
+ it("gets card image attribution values instead of story attribution values on card share", function () {
302
251
  const story = {
303
252
  "hero-image-s3-key": "my/image.png",
304
253
  headline: "story headline",
@@ -315,38 +264,31 @@ describe("ImageTags", function() {
315
264
  metadata: {
316
265
  width: 1300,
317
266
  height: 1065,
318
- "mime-type": "image/jpeg"
319
- }
320
- }
321
- }
322
- }
323
- }
324
- ]
267
+ "mime-type": "image/jpeg",
268
+ },
269
+ },
270
+ },
271
+ },
272
+ },
273
+ ],
325
274
  };
326
275
 
327
276
  const opts = {
328
277
  url: {
329
278
  query: {
330
- cardId: "sample-card-id"
331
- }
332
- }
279
+ cardId: "sample-card-id",
280
+ },
281
+ },
333
282
  };
334
283
 
335
- const string = getSeoMetadata(
336
- seoConfig,
337
- config,
338
- "story-page",
339
- { data: { story: story } },
340
- opts
341
- );
342
-
343
- assertContains('<meta property="twitter:image:alt" content="attribution test"/>', string)
284
+ const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, opts);
344
285
 
345
- assertContains('<meta property="og:image:alt" content="attribution test"/>', string)
286
+ assertContains('<meta property="twitter:image:alt" content="attribution test"/>', string);
346
287
 
288
+ assertContains('<meta property="og:image:alt" content="attribution test"/>', string);
347
289
  });
348
290
 
349
- it("gets story data as fallback if the card metadata is falsy", function() {
291
+ it("gets story data as fallback if the card metadata is falsy", function () {
350
292
  const story = {
351
293
  "hero-image-s3-key": "my/image.png",
352
294
  cards: [
@@ -355,48 +297,36 @@ describe("ImageTags", function() {
355
297
  metadata: {
356
298
  "social-share": {
357
299
  title: "share-card-title",
358
- message: "share-card-description"
359
- }
360
- }
361
- }
362
- ]
300
+ message: "share-card-description",
301
+ },
302
+ },
303
+ },
304
+ ],
363
305
  };
364
306
 
365
307
  const opts = {
366
308
  url: {
367
309
  query: {
368
- cardId: "sample-card-id"
369
- }
370
- }
310
+ cardId: "sample-card-id",
311
+ },
312
+ },
371
313
  };
372
314
 
373
- const string = getSeoMetadata(
374
- seoConfig,
375
- config,
376
- "story-page",
377
- { data: { story: story } },
378
- opts
379
- );
380
- const ampPageString = getSeoMetadata(
381
- seoConfig,
382
- config,
383
- "story-page-amp",
384
- { data: { story: story } },
385
- opts
386
- );
315
+ const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, opts);
316
+ const ampPageString = getSeoMetadata(seoConfig, config, "story-page-amp", { data: { story: story } }, opts);
387
317
 
388
318
  assertContains(
389
- '<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fimage.png?w=1200&amp;auto=format%2Ccompress&amp;ogImage=true"/>',
319
+ '<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fimage.png?w=1200&amp;auto=format%2Ccompress&amp;ogImage=true&amp;enlarge=true"/>',
390
320
  string
391
321
  );
392
322
  assertContains(
393
- '<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fimage.png?w=1200&amp;auto=format%2Ccompress&amp;ogImage=true"/>',
323
+ '<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fimage.png?w=1200&amp;auto=format%2Ccompress&amp;ogImage=true&amp;enlarge=true"/>',
394
324
  ampPageString
395
325
  );
396
326
  });
397
327
 
398
- describe("for collection pages", function() {
399
- it("pulls images from the collection if present", function() {
328
+ describe("for collection pages", function () {
329
+ it("pulls images from the collection if present", function () {
400
330
  const collection = {
401
331
  metadata: {
402
332
  "cover-image": {
@@ -404,33 +334,21 @@ describe("ImageTags", function() {
404
334
  "cover-image-metadata": {
405
335
  width: 2400,
406
336
  height: 1260,
407
- "focus-point": [0, 0]
408
- }
409
- }
410
- }
337
+ "focus-point": [0, 0],
338
+ },
339
+ },
340
+ },
411
341
  };
412
- const string = getSeoMetadata(
413
- seoConfig,
414
- config,
415
- "home-page",
416
- { data: { collection: collection } },
417
- {}
418
- );
419
- assertContains(
420
- '<meta property="og:image" content="https://thumbor.assettype.com/my%2Fimage.png?rect=0%2C0%2C2400%2C1260&amp;w=1200&amp;auto=format%2Ccompress&amp;ogImage=true"/>',
421
- string
422
- );
342
+ const string = getSeoMetadata(seoConfig, config, "home-page", { data: { collection: collection } }, {});
423
343
  assertContains(
424
- '<meta property="og:image:width" content="1200"/>',
425
- string
426
- );
427
- assertContains(
428
- '<meta property="og:image:height" content="630"/>',
344
+ '<meta property="og:image" content="https://thumbor.assettype.com/my%2Fimage.png?rect=0%2C0%2C2400%2C1260&amp;w=1200&amp;auto=format%2Ccompress&amp;ogImage=true&amp;enlarge=true"/>',
429
345
  string
430
346
  );
347
+ assertContains('<meta property="og:image:width" content="1200"/>', string);
348
+ assertContains('<meta property="og:image:height" content="630"/>', string);
431
349
  });
432
350
 
433
- it("pulls images with alt from the collection if present", function() {
351
+ it("pulls images with alt from the collection if present", function () {
434
352
  const collection = {
435
353
  name: "collection name",
436
354
  summary: "collection summary",
@@ -440,41 +358,23 @@ describe("ImageTags", function() {
440
358
  "cover-image-metadata": {
441
359
  width: 2400,
442
360
  height: 1260,
443
- "focus-point": [0, 0]
444
- }
445
- }
446
- }
361
+ "focus-point": [0, 0],
362
+ },
363
+ },
364
+ },
447
365
  };
448
- const string = getSeoMetadata(
449
- seoConfig,
450
- config,
451
- "home-page",
452
- { data: { collection: collection } },
453
- {}
454
- );
455
- assertContains(
456
- '<meta property="og:image:alt" content="collection summary"/>',
457
- string
458
- );
459
- assertContains(
460
- '<meta property="twitter:image:alt" content="collection summary"/>',
461
- string
462
- );
366
+ const string = getSeoMetadata(seoConfig, config, "home-page", { data: { collection: collection } }, {});
367
+ assertContains('<meta property="og:image:alt" content="collection summary"/>', string);
368
+ assertContains('<meta property="twitter:image:alt" content="collection summary"/>', string);
463
369
  });
464
370
 
465
- it("does not add tags if the cover image is missing", function() {
371
+ it("does not add tags if the cover image is missing", function () {
466
372
  const collection = {
467
373
  metadata: {
468
- "cover-image": {}
469
- }
374
+ "cover-image": {},
375
+ },
470
376
  };
471
- const string = getSeoMetadata(
472
- seoConfig,
473
- config,
474
- "home-page",
475
- { data: { collection: collection } },
476
- {}
477
- );
377
+ const string = getSeoMetadata(seoConfig, config, "home-page", { data: { collection: collection } }, {});
478
378
  assert.equal("", string);
479
379
  });
480
380
  });