@quintype/seo 1.42.0-watermark-feature.12 → 1.42.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/CHANGELOG.md +13 -0
- package/dist/index.cjs.js +18 -59
- package/package.json +2 -4
- package/src/image-tags.js +16 -49
- package/src/structured-data/structured-data-tags.js +0 -1
- package/src/text-tags.js +0 -1
- package/src/utils.js +13 -20
- package/test/image_tags_test.js +8 -77
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
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.42.0](https://github.com/quintype/quintype-node-seo/compare/v1.40.13...v1.42.0) (2023-04-03)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **canonical:** Add canonical url toggle ([#539](https://github.com/quintype/quintype-node-seo/issues/539)) ([3c18124](https://github.com/quintype/quintype-node-seo/commit/3c181249b7adb06061a8a4c16aa71b640b21679c))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **canonical:** Toggle canonical tags ([1f8a4fe](https://github.com/quintype/quintype-node-seo/commit/1f8a4fe0955688080095275290dabe79dc6344d6))
|
|
16
|
+
* **dates:** update datePublished ([#537](https://github.com/quintype/quintype-node-seo/issues/537)) ([b81f1ae](https://github.com/quintype/quintype-node-seo/commit/b81f1aeef63937673f376203a8d7a45b7a0de2b3))
|
|
17
|
+
|
|
5
18
|
### [1.41.4](https://github.com/quintype/quintype-node-seo/compare/v1.41.4-gsc-errors-fix.0...v1.41.4) (2022-12-12)
|
|
6
19
|
|
|
7
20
|
### [1.41.3](https://github.com/quintype/quintype-node-seo/compare/v1.41.2...v1.41.3) (2022-12-02)
|
package/dist/index.cjs.js
CHANGED
|
@@ -6,8 +6,8 @@ var lodash = require('lodash');
|
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var ReactDomServer = require('react-dom/server');
|
|
8
8
|
var get = require('lodash/get');
|
|
9
|
-
var dateFnsTz = require('date-fns-tz');
|
|
10
9
|
var url = require('url');
|
|
10
|
+
var dateFnsTz = require('date-fns-tz');
|
|
11
11
|
var isUndefined = require('lodash/isUndefined');
|
|
12
12
|
var omitBy = require('lodash/omitBy');
|
|
13
13
|
var quintypeJs = require('quintype-js');
|
|
@@ -25,7 +25,7 @@ function objectToTags(object) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
function getPropertyName(key) {
|
|
28
|
-
return key.startsWith(
|
|
28
|
+
return key.startsWith('fb:') || key.startsWith('og:') ? 'property' : 'name';
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
function stripMillisecondsFromTime(date, timezone) {
|
|
@@ -33,28 +33,20 @@ function stripMillisecondsFromTime(date, timezone) {
|
|
|
33
33
|
if (!toReturn) return toReturn;
|
|
34
34
|
const zonedTime = timezone && dateFnsTz.utcToZonedTime(date, timezone);
|
|
35
35
|
const formatZonedTime = zonedTime && dateFnsTz.format(zonedTime, "yyyy-MM-dd'T'HH:mm:ssXXX", { timeZone: timezone });
|
|
36
|
-
const formatToReturn = toReturn.split(
|
|
36
|
+
const formatToReturn = toReturn.split('.')[0] + "Z";
|
|
37
37
|
return timezone ? formatZonedTime : formatToReturn;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
function getQueryParams(url$1) {
|
|
41
41
|
const urlObj = new url.URL(url$1);
|
|
42
42
|
const search_params = new url.URLSearchParams(urlObj.search);
|
|
43
|
-
const getWidth = search_params.get(
|
|
44
|
-
const getHeight = search_params.get(
|
|
43
|
+
const getWidth = search_params.get('w') || '';
|
|
44
|
+
const getHeight = search_params.get('h') || '';
|
|
45
45
|
return { width: getWidth, height: getHeight };
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function isStoryPublic(story) {
|
|
49
|
-
return story.access === undefined || story.access === null || story.access ===
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function getWatermarkImage(story, cdnSrc, cdnURL) {
|
|
53
|
-
const watermarkImageS3Key = lodash.get(story, ["watermark", "social", "image-s3-key"], "");
|
|
54
|
-
if (cdnSrc && cdnSrc.includes("gumlet") && watermarkImageS3Key.length > 0) {
|
|
55
|
-
return `https://${cdnURL}/${watermarkImageS3Key}`;
|
|
56
|
-
}
|
|
57
|
-
return watermarkImageS3Key;
|
|
49
|
+
return story.access === undefined || story.access === null || story.access === 'public';
|
|
58
50
|
}
|
|
59
51
|
|
|
60
52
|
function showAmpTag({ ampStoryPages = true }, pageType, story) {
|
|
@@ -328,13 +320,6 @@ function pickImage({ pageType, config, seoConfig, data, url }) {
|
|
|
328
320
|
*/
|
|
329
321
|
function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
|
|
330
322
|
const { image, alt, includesHost = false } = pickImage({ pageType, data, url, seoConfig, config });
|
|
331
|
-
const dataObj = lodash.get(data, ["data"], {});
|
|
332
|
-
const story = lodash.get(dataObj, ["story"], {});
|
|
333
|
-
const publisherConfig = lodash.get(data, ["config", "publisher-attributes"], {});
|
|
334
|
-
const fallbackValue = dataObj.hasOwnProperty("collection") ? true : false;
|
|
335
|
-
const isWatermarkDisabled = lodash.get(story, ["metadata", "watermark-image", "disabled"], fallbackValue);
|
|
336
|
-
const imageCdnSrc = publisherConfig.cdn_src;
|
|
337
|
-
const imageCdnUrl = publisherConfig.cdn_image || config["cdn-image"];
|
|
338
323
|
|
|
339
324
|
if (!image) {
|
|
340
325
|
return [];
|
|
@@ -346,44 +331,15 @@ function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
|
|
|
346
331
|
tags.push({ name: "robots", content: "max-image-preview:large" });
|
|
347
332
|
}
|
|
348
333
|
|
|
349
|
-
const getImageUrl = (imageRatio, imageProp) => {
|
|
350
|
-
return includesHost ? image : `https://${imageCdnUrl}/${image.path(imageRatio, imageProp)}`;
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
const getContent = (actualImageAR, watermarkImageAR) => {
|
|
354
|
-
const actualImageProp = {
|
|
355
|
-
w: 1200,
|
|
356
|
-
ar: actualImageAR.join(":"),
|
|
357
|
-
auto: "format,compress",
|
|
358
|
-
ogImage: true,
|
|
359
|
-
mode: "crop",
|
|
360
|
-
enlarge: true
|
|
361
|
-
};
|
|
362
|
-
const watermarkImageProp = {
|
|
363
|
-
w: 1200,
|
|
364
|
-
ar: watermarkImageAR.join(":"),
|
|
365
|
-
auto: "format,compress",
|
|
366
|
-
ogImage: true,
|
|
367
|
-
mode: "crop",
|
|
368
|
-
enlarge: true
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
const overlayWatermarkProp = Object.assign({}, watermarkImageProp, {
|
|
372
|
-
overlay: getWatermarkImage(story, imageCdnSrc, imageCdnUrl),
|
|
373
|
-
overlay_position: "bottom"
|
|
374
|
-
});
|
|
375
|
-
const updatedOverlay = imageCdnSrc && imageCdnSrc.includes("gumlet") ? Object.assign({}, overlayWatermarkProp, {
|
|
376
|
-
overlay_width_pct: 1
|
|
377
|
-
}) : Object.assign({}, overlayWatermarkProp, {
|
|
378
|
-
overlay_width: 100
|
|
379
|
-
});
|
|
380
|
-
return isWatermarkDisabled ? getImageUrl(actualImageAR, actualImageProp) : getImageUrl(watermarkImageAR, updatedOverlay);
|
|
381
|
-
};
|
|
382
|
-
|
|
383
334
|
if (seoConfig.enableTwitterCards) {
|
|
384
335
|
tags.push({
|
|
385
336
|
name: "twitter:image",
|
|
386
|
-
content:
|
|
337
|
+
content: includesHost ? image : `https://${config["cdn-image"]}/${image.path([16, 9], {
|
|
338
|
+
w: 1200,
|
|
339
|
+
auto: "format,compress",
|
|
340
|
+
ogImage: true,
|
|
341
|
+
enlarge: true
|
|
342
|
+
})}`
|
|
387
343
|
});
|
|
388
344
|
alt && tags.push({ property: "twitter:image:alt", content: alt });
|
|
389
345
|
}
|
|
@@ -391,7 +347,12 @@ function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
|
|
|
391
347
|
if (seoConfig.enableOgTags) {
|
|
392
348
|
tags.push({
|
|
393
349
|
property: "og:image",
|
|
394
|
-
content:
|
|
350
|
+
content: includesHost ? image : `https://${config["cdn-image"]}/${image.path([40, 21], {
|
|
351
|
+
w: 1200,
|
|
352
|
+
auto: "format,compress",
|
|
353
|
+
ogImage: true,
|
|
354
|
+
enlarge: true
|
|
355
|
+
})}`
|
|
395
356
|
});
|
|
396
357
|
tags.push({ property: "og:image:width", content: 1200 });
|
|
397
358
|
if (lodash.get(image, ["metadata", "focus-point"])) {
|
|
@@ -626,7 +587,6 @@ function generateArticleData(structuredData = {}, story = {}, publisherConfig =
|
|
|
626
587
|
function generateArticleImageData(image, publisherConfig = {}) {
|
|
627
588
|
const imageWidth = 1200;
|
|
628
589
|
const imageHeight = 675;
|
|
629
|
-
|
|
630
590
|
const articleImage = imageUrl(publisherConfig, image, imageWidth, imageHeight);
|
|
631
591
|
|
|
632
592
|
return Object.assign({}, {
|
|
@@ -1113,7 +1073,6 @@ function buildCustomTags(customTags = {}, pageType = "") {
|
|
|
1113
1073
|
function buildTagsFromStaticPage(config, page, url = {}, data) {
|
|
1114
1074
|
const seoData = lodash.get(page, ["metadata", "seo"], {});
|
|
1115
1075
|
const customSeo = lodash.get(data, ["data", "customSeo"], {});
|
|
1116
|
-
if (lodash.isEmpty(seoData) && lodash.isEmpty(customSeo)) return;
|
|
1117
1076
|
|
|
1118
1077
|
const { "meta-title": metaTitle, "meta-description": metaDescription, "meta-keywords": keywords } = seoData;
|
|
1119
1078
|
|
package/package.json
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quintype/seo",
|
|
3
|
-
"version": "1.42.0
|
|
3
|
+
"version": "1.42.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",
|
|
7
7
|
"author": "Quintype Developers <dev-core@quintype.com>",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"peerDependencies": {
|
|
10
|
-
"lodash": "^4.0.0"
|
|
11
|
-
"react": "^16.0.0",
|
|
12
|
-
"react-dom": "^16.0.0"
|
|
10
|
+
"lodash": "^4.0.0"
|
|
13
11
|
},
|
|
14
12
|
"scripts": {
|
|
15
13
|
"build": "rollup -c",
|
package/src/image-tags.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { get, isEmpty } from "lodash";
|
|
2
2
|
import { FocusedImage } from "quintype-js";
|
|
3
|
-
import { getWatermarkImage } from "./utils";
|
|
4
3
|
|
|
5
4
|
function pickImageFromCard(story, cardId) {
|
|
6
5
|
const { metadata = {} } = story.cards.find((card) => card.id === cardId) || {};
|
|
@@ -113,13 +112,6 @@ function pickImage({ pageType, config, seoConfig, data, url }) {
|
|
|
113
112
|
*/
|
|
114
113
|
export function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
|
|
115
114
|
const { image, alt, includesHost = false } = pickImage({ pageType, data, url, seoConfig, config });
|
|
116
|
-
const dataObj = get(data, ["data"], {});
|
|
117
|
-
const story = get(dataObj, ["story"], {});
|
|
118
|
-
const publisherConfig = get(data, ["config", "publisher-attributes"], {});
|
|
119
|
-
const fallbackValue = dataObj.hasOwnProperty("collection") ? true : false;
|
|
120
|
-
const isWatermarkDisabled = get(story, ["metadata", "watermark-image", "disabled"], fallbackValue);
|
|
121
|
-
const imageCdnSrc = publisherConfig.cdn_src;
|
|
122
|
-
const imageCdnUrl = publisherConfig.cdn_image || config["cdn-image"];
|
|
123
115
|
|
|
124
116
|
if (!image) {
|
|
125
117
|
return [];
|
|
@@ -131,49 +123,17 @@ export function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
|
|
|
131
123
|
tags.push({ name: "robots", content: "max-image-preview:large" });
|
|
132
124
|
}
|
|
133
125
|
|
|
134
|
-
const getImageUrl = (imageRatio, imageProp) => {
|
|
135
|
-
return includesHost ? image : `https://${imageCdnUrl}/${image.path(imageRatio, imageProp)}`;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const getContent = (actualImageAR, watermarkImageAR) => {
|
|
139
|
-
const actualImageProp = {
|
|
140
|
-
w: 1200,
|
|
141
|
-
ar: actualImageAR.join(":"),
|
|
142
|
-
auto: "format,compress",
|
|
143
|
-
ogImage: true,
|
|
144
|
-
mode: "crop",
|
|
145
|
-
enlarge: true,
|
|
146
|
-
};
|
|
147
|
-
const watermarkImageProp = {
|
|
148
|
-
w: 1200,
|
|
149
|
-
ar: watermarkImageAR.join(":"),
|
|
150
|
-
auto: "format,compress",
|
|
151
|
-
ogImage: true,
|
|
152
|
-
mode: "crop",
|
|
153
|
-
enlarge: true,
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const overlayWatermarkProp = Object.assign({}, watermarkImageProp, {
|
|
157
|
-
overlay: getWatermarkImage(story, imageCdnSrc, imageCdnUrl),
|
|
158
|
-
overlay_position: "bottom",
|
|
159
|
-
});
|
|
160
|
-
const updatedOverlay =
|
|
161
|
-
imageCdnSrc && imageCdnSrc.includes("gumlet")
|
|
162
|
-
? Object.assign({}, overlayWatermarkProp, {
|
|
163
|
-
overlay_width_pct: 1,
|
|
164
|
-
})
|
|
165
|
-
: Object.assign({}, overlayWatermarkProp, {
|
|
166
|
-
overlay_width: 100,
|
|
167
|
-
});
|
|
168
|
-
return isWatermarkDisabled
|
|
169
|
-
? getImageUrl(actualImageAR, actualImageProp)
|
|
170
|
-
: getImageUrl(watermarkImageAR, updatedOverlay);
|
|
171
|
-
};
|
|
172
|
-
|
|
173
126
|
if (seoConfig.enableTwitterCards) {
|
|
174
127
|
tags.push({
|
|
175
128
|
name: "twitter:image",
|
|
176
|
-
content:
|
|
129
|
+
content: includesHost
|
|
130
|
+
? image
|
|
131
|
+
: `https://${config["cdn-image"]}/${image.path([16, 9], {
|
|
132
|
+
w: 1200,
|
|
133
|
+
auto: "format,compress",
|
|
134
|
+
ogImage: true,
|
|
135
|
+
enlarge: true,
|
|
136
|
+
})}`,
|
|
177
137
|
});
|
|
178
138
|
alt && tags.push({ property: "twitter:image:alt", content: alt });
|
|
179
139
|
}
|
|
@@ -181,7 +141,14 @@ export function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
|
|
|
181
141
|
if (seoConfig.enableOgTags) {
|
|
182
142
|
tags.push({
|
|
183
143
|
property: "og:image",
|
|
184
|
-
content:
|
|
144
|
+
content: includesHost
|
|
145
|
+
? image
|
|
146
|
+
: `https://${config["cdn-image"]}/${image.path([40, 21], {
|
|
147
|
+
w: 1200,
|
|
148
|
+
auto: "format,compress",
|
|
149
|
+
ogImage: true,
|
|
150
|
+
enlarge: true,
|
|
151
|
+
})}`,
|
|
185
152
|
});
|
|
186
153
|
tags.push({ property: "og:image:width", content: 1200 });
|
|
187
154
|
if (get(image, ["metadata", "focus-point"])) {
|
|
@@ -129,7 +129,6 @@ function generateArticleData(structuredData = {}, story = {}, publisherConfig =
|
|
|
129
129
|
function generateArticleImageData(image, publisherConfig = {}) {
|
|
130
130
|
const imageWidth = 1200;
|
|
131
131
|
const imageHeight = 675;
|
|
132
|
-
|
|
133
132
|
const articleImage = imageUrl(publisherConfig, image, imageWidth, imageHeight);
|
|
134
133
|
|
|
135
134
|
return Object.assign(
|
package/src/text-tags.js
CHANGED
|
@@ -144,7 +144,6 @@ function buildCustomTags(customTags = {}, pageType = "") {
|
|
|
144
144
|
function buildTagsFromStaticPage(config, page, url = {}, data) {
|
|
145
145
|
const seoData = get(page, ["metadata", "seo"], {});
|
|
146
146
|
const customSeo = get(data, ["data", "customSeo"], {});
|
|
147
|
-
if (isEmpty(seoData) && isEmpty(customSeo)) return;
|
|
148
147
|
|
|
149
148
|
const { "meta-title": metaTitle, "meta-description": metaDescription, "meta-keywords": keywords } = seoData;
|
|
150
149
|
|
package/src/utils.js
CHANGED
|
@@ -1,42 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import {entries} from 'lodash';
|
|
2
|
+
import { URL, URLSearchParams } from 'url';
|
|
3
|
+
import { format, utcToZonedTime } from 'date-fns-tz';
|
|
4
4
|
|
|
5
5
|
export function objectToTags(object) {
|
|
6
6
|
return entries(object)
|
|
7
7
|
.filter(([key, value]) => value)
|
|
8
|
-
.map(([key, value]) => ({
|
|
8
|
+
.map(([key, value]) => ({[getPropertyName(key)]: key, content: value}));
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
function getPropertyName(key) {
|
|
12
|
-
return key.startsWith(
|
|
12
|
+
return (key.startsWith('fb:') || key.startsWith('og:')) ? 'property' : 'name';
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export function stripMillisecondsFromTime(date, timezone) {
|
|
16
16
|
const toReturn = date.toJSON();
|
|
17
|
-
if
|
|
17
|
+
if(!toReturn)
|
|
18
|
+
return toReturn
|
|
18
19
|
const zonedTime = timezone && utcToZonedTime(date, timezone);
|
|
19
20
|
const formatZonedTime = zonedTime && format(zonedTime, "yyyy-MM-dd'T'HH:mm:ssXXX", { timeZone: timezone });
|
|
20
|
-
const formatToReturn = toReturn.split(
|
|
21
|
+
const formatToReturn = toReturn.split('.')[0]+"Z";
|
|
21
22
|
return timezone ? formatZonedTime : formatToReturn;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export function getQueryParams(url) {
|
|
25
|
-
const urlObj =
|
|
26
|
+
const urlObj = new URL(url);
|
|
26
27
|
const search_params = new URLSearchParams(urlObj.search);
|
|
27
|
-
const getWidth = search_params.get(
|
|
28
|
-
const getHeight = search_params.get(
|
|
29
|
-
return {
|
|
28
|
+
const getWidth = search_params.get('w') || '';
|
|
29
|
+
const getHeight = search_params.get('h') || '';
|
|
30
|
+
return {width: getWidth, height: getHeight};
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
export function isStoryPublic(story) {
|
|
33
|
-
return story.access === undefined || story.access === null || story.access ===
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function getWatermarkImage(story, cdnSrc, cdnURL) {
|
|
37
|
-
const watermarkImageS3Key = get(story, ["watermark", "social", "image-s3-key"], "");
|
|
38
|
-
if (cdnSrc && cdnSrc.includes("gumlet") && watermarkImageS3Key.length > 0) {
|
|
39
|
-
return `https://${cdnURL}/${watermarkImageS3Key}`;
|
|
40
|
-
}
|
|
41
|
-
return watermarkImageS3Key;
|
|
34
|
+
return story.access === undefined || story.access === null || story.access === 'public';
|
|
42
35
|
}
|
package/test/image_tags_test.js
CHANGED
|
@@ -17,16 +17,6 @@ describe("ImageTags", function () {
|
|
|
17
17
|
it("gets the twitter tags", function () {
|
|
18
18
|
const story = {
|
|
19
19
|
"hero-image-s3-key": "my/image.png",
|
|
20
|
-
metadata: {
|
|
21
|
-
"watermark-image": {
|
|
22
|
-
disabled: true,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
watermark: {
|
|
26
|
-
social: {
|
|
27
|
-
"image-s3-key": "my/watermark-image.png",
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
20
|
alternative: {
|
|
31
21
|
social: {
|
|
32
22
|
default: {
|
|
@@ -49,55 +39,11 @@ describe("ImageTags", function () {
|
|
|
49
39
|
const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, {});
|
|
50
40
|
const ampPageString = getSeoMetadata(seoConfig, config, "story-page-amp", { data: { story: story } }, {});
|
|
51
41
|
assertContains(
|
|
52
|
-
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?w=1200&
|
|
42
|
+
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?w=1200&auto=format%2Ccompress&ogImage=true&enlarge=true"/>',
|
|
53
43
|
string
|
|
54
44
|
);
|
|
55
45
|
assertContains(
|
|
56
|
-
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?w=1200&
|
|
57
|
-
ampPageString
|
|
58
|
-
);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("gets the twitter tags with watermark", function () {
|
|
62
|
-
const story = {
|
|
63
|
-
"hero-image-s3-key": "my/image.png",
|
|
64
|
-
metadata: {
|
|
65
|
-
"watermark-image": {
|
|
66
|
-
disabled: false,
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
watermark: {
|
|
70
|
-
social: {
|
|
71
|
-
"image-s3-key": "my/watermark-image.png",
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
alternative: {
|
|
75
|
-
social: {
|
|
76
|
-
default: {
|
|
77
|
-
headline: null,
|
|
78
|
-
"hero-image": {
|
|
79
|
-
"hero-image-s3-key": "my/socialimage.png",
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
home: {
|
|
84
|
-
default: {
|
|
85
|
-
headline: null,
|
|
86
|
-
"hero-image": {
|
|
87
|
-
"hero-image-s3-key": "my/homeimage.png",
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, {});
|
|
94
|
-
const ampPageString = getSeoMetadata(seoConfig, config, "story-page-amp", { data: { story: story } }, {});
|
|
95
|
-
assertContains(
|
|
96
|
-
'<meta property="og:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?w=1200&ar=40%3A21&auto=format%2Ccompress&ogImage=true&mode=crop&enlarge=true&overlay=my%2Fwatermark-image.png&overlay_position=bottom&overlay_width=100"/>',
|
|
97
|
-
string
|
|
98
|
-
);
|
|
99
|
-
assertContains(
|
|
100
|
-
'<meta property="og:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?w=1200&ar=40%3A21&auto=format%2Ccompress&ogImage=true&mode=crop&enlarge=true&overlay=my%2Fwatermark-image.png&overlay_position=bottom&overlay_width=100"/>',
|
|
46
|
+
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?w=1200&auto=format%2Ccompress&ogImage=true&enlarge=true"/>',
|
|
101
47
|
ampPageString
|
|
102
48
|
);
|
|
103
49
|
});
|
|
@@ -132,11 +78,6 @@ describe("ImageTags", function () {
|
|
|
132
78
|
it("has facebook tags resized correctly", function () {
|
|
133
79
|
const story = {
|
|
134
80
|
"hero-image-s3-key": "my/images.png",
|
|
135
|
-
metadata: {
|
|
136
|
-
"watermark-image": {
|
|
137
|
-
disabled: true,
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
81
|
"hero-image-metadata": {
|
|
141
82
|
width: 2400,
|
|
142
83
|
height: 1260,
|
|
@@ -174,11 +115,11 @@ describe("ImageTags", function () {
|
|
|
174
115
|
const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, {});
|
|
175
116
|
const ampPageString = getSeoMetadata(seoConfig, config, "story-page-amp", { data: { story: story } }, {});
|
|
176
117
|
assertContains(
|
|
177
|
-
'<meta property="og:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?rect=0%2C0%2C2400%2C1260&w=1200&
|
|
118
|
+
'<meta property="og:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?rect=0%2C0%2C2400%2C1260&w=1200&auto=format%2Ccompress&ogImage=true&enlarge=true"/>',
|
|
178
119
|
string
|
|
179
120
|
);
|
|
180
121
|
assertContains(
|
|
181
|
-
'<meta property="og:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?rect=0%2C0%2C2400%2C1260&w=1200&
|
|
122
|
+
'<meta property="og:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?rect=0%2C0%2C2400%2C1260&w=1200&auto=format%2Ccompress&ogImage=true&enlarge=true"/>',
|
|
182
123
|
ampPageString
|
|
183
124
|
);
|
|
184
125
|
assertContains('<meta property="og:image:width" content="1200"/>', string);
|
|
@@ -190,11 +131,6 @@ describe("ImageTags", function () {
|
|
|
190
131
|
it("gets card image values instead of story image values on card share", function () {
|
|
191
132
|
const story = {
|
|
192
133
|
"hero-image-s3-key": "my/image.png",
|
|
193
|
-
metadata: {
|
|
194
|
-
"watermark-image": {
|
|
195
|
-
disabled: true,
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
134
|
cards: [
|
|
199
135
|
{
|
|
200
136
|
id: "sample-card-id",
|
|
@@ -227,7 +163,7 @@ describe("ImageTags", function () {
|
|
|
227
163
|
const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, opts);
|
|
228
164
|
|
|
229
165
|
assertContains(
|
|
230
|
-
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fcard%2Fimage.jpg?w=1200&
|
|
166
|
+
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fcard%2Fimage.jpg?w=1200&auto=format%2Ccompress&ogImage=true&enlarge=true"/>',
|
|
231
167
|
string
|
|
232
168
|
);
|
|
233
169
|
});
|
|
@@ -382,11 +318,6 @@ describe("ImageTags", function () {
|
|
|
382
318
|
it("gets story data as fallback if the card metadata is falsy", function () {
|
|
383
319
|
const story = {
|
|
384
320
|
"hero-image-s3-key": "my/image.png",
|
|
385
|
-
metadata: {
|
|
386
|
-
"watermark-image": {
|
|
387
|
-
disabled: true,
|
|
388
|
-
},
|
|
389
|
-
},
|
|
390
321
|
cards: [
|
|
391
322
|
{
|
|
392
323
|
id: "sample-card-id",
|
|
@@ -412,11 +343,11 @@ describe("ImageTags", function () {
|
|
|
412
343
|
const ampPageString = getSeoMetadata(seoConfig, config, "story-page-amp", { data: { story: story } }, opts);
|
|
413
344
|
|
|
414
345
|
assertContains(
|
|
415
|
-
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fimage.png?w=1200&
|
|
346
|
+
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fimage.png?w=1200&auto=format%2Ccompress&ogImage=true&enlarge=true"/>',
|
|
416
347
|
string
|
|
417
348
|
);
|
|
418
349
|
assertContains(
|
|
419
|
-
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fimage.png?w=1200&
|
|
350
|
+
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fimage.png?w=1200&auto=format%2Ccompress&ogImage=true&enlarge=true"/>',
|
|
420
351
|
ampPageString
|
|
421
352
|
);
|
|
422
353
|
});
|
|
@@ -437,7 +368,7 @@ describe("ImageTags", function () {
|
|
|
437
368
|
};
|
|
438
369
|
const string = getSeoMetadata(seoConfig, config, "home-page", { data: { collection: collection } }, {});
|
|
439
370
|
assertContains(
|
|
440
|
-
'<meta property="og:image" content="https://thumbor.assettype.com/my%2Fimage.png?rect=0%2C0%2C2400%2C1260&w=1200&
|
|
371
|
+
'<meta property="og:image" content="https://thumbor.assettype.com/my%2Fimage.png?rect=0%2C0%2C2400%2C1260&w=1200&auto=format%2Ccompress&ogImage=true&enlarge=true"/>',
|
|
441
372
|
string
|
|
442
373
|
);
|
|
443
374
|
assertContains('<meta property="og:image:width" content="1200"/>', string);
|