@quintype/seo 1.42.0-watermark-feature.13 → 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 -67
- package/package.json +2 -4
- package/src/image-tags.js +16 -55
- 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,14 +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
|
-
const fallbackSocialImage = lodash.get(seoConfig, ["fallbackSocialImage"]);
|
|
339
323
|
|
|
340
324
|
if (!image) {
|
|
341
325
|
return [];
|
|
@@ -346,52 +330,16 @@ function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
|
|
|
346
330
|
if (pageType == "story-page") {
|
|
347
331
|
tags.push({ name: "robots", content: "max-image-preview:large" });
|
|
348
332
|
}
|
|
349
|
-
const getHeroImage = (imageRatio, imageProp) => {
|
|
350
|
-
return includesHost ? image : `https://${imageCdnUrl}/${image.path(imageRatio, imageProp)}`;
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
const getWatermarkHeroImage = (imageRatio, imageProp) => {
|
|
354
|
-
const overlayWatermarkProps = Object.assign({}, imageProp, {
|
|
355
|
-
overlay: getWatermarkImage(story, imageCdnSrc, imageCdnUrl),
|
|
356
|
-
overlay_position: "bottom"
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
const watermarkImageProps = imageCdnSrc && imageCdnSrc.includes("gumlet") ? Object.assign({}, overlayWatermarkProps, {
|
|
360
|
-
overlay_width_pct: 1
|
|
361
|
-
}) : Object.assign({}, overlayWatermarkProps, {
|
|
362
|
-
overlay_width: 100
|
|
363
|
-
});
|
|
364
|
-
|
|
365
|
-
const getFallbackImage = () => {
|
|
366
|
-
if (fallbackSocialImage) {
|
|
367
|
-
const fbUrl = new URL(fallbackSocialImage);
|
|
368
|
-
const fbImageSlug = new quintypeJs.FocusedImage(fbUrl.href.slice(fbUrl.origin.length + 1));
|
|
369
|
-
const fbHost = new URL(fallbackSocialImage).origin;
|
|
370
|
-
return `${fbHost}/${fbImageSlug.path(imageRatio, watermarkImageProps)}`;
|
|
371
|
-
} else {
|
|
372
|
-
return image;
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
return includesHost ? getFallbackImage() : `https://${imageCdnUrl}/${image.path(imageRatio, watermarkImageProps)}`;
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
const getImageContent = imageRatio => {
|
|
380
|
-
const imageProp = {
|
|
381
|
-
w: 1200,
|
|
382
|
-
ar: imageRatio.join(":"),
|
|
383
|
-
auto: "format,compress",
|
|
384
|
-
ogImage: true,
|
|
385
|
-
mode: "crop",
|
|
386
|
-
enlarge: true
|
|
387
|
-
};
|
|
388
|
-
return isWatermarkDisabled ? getHeroImage(imageRatio, imageProp) : getWatermarkHeroImage(imageRatio, imageProp);
|
|
389
|
-
};
|
|
390
333
|
|
|
391
334
|
if (seoConfig.enableTwitterCards) {
|
|
392
335
|
tags.push({
|
|
393
336
|
name: "twitter:image",
|
|
394
|
-
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
|
+
})}`
|
|
395
343
|
});
|
|
396
344
|
alt && tags.push({ property: "twitter:image:alt", content: alt });
|
|
397
345
|
}
|
|
@@ -399,7 +347,12 @@ function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
|
|
|
399
347
|
if (seoConfig.enableOgTags) {
|
|
400
348
|
tags.push({
|
|
401
349
|
property: "og:image",
|
|
402
|
-
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
|
+
})}`
|
|
403
356
|
});
|
|
404
357
|
tags.push({ property: "og:image:width", content: 1200 });
|
|
405
358
|
if (lodash.get(image, ["metadata", "focus-point"])) {
|
|
@@ -634,7 +587,6 @@ function generateArticleData(structuredData = {}, story = {}, publisherConfig =
|
|
|
634
587
|
function generateArticleImageData(image, publisherConfig = {}) {
|
|
635
588
|
const imageWidth = 1200;
|
|
636
589
|
const imageHeight = 675;
|
|
637
|
-
|
|
638
590
|
const articleImage = imageUrl(publisherConfig, image, imageWidth, imageHeight);
|
|
639
591
|
|
|
640
592
|
return Object.assign({}, {
|
|
@@ -1121,7 +1073,6 @@ function buildCustomTags(customTags = {}, pageType = "") {
|
|
|
1121
1073
|
function buildTagsFromStaticPage(config, page, url = {}, data) {
|
|
1122
1074
|
const seoData = lodash.get(page, ["metadata", "seo"], {});
|
|
1123
1075
|
const customSeo = lodash.get(data, ["data", "customSeo"], {});
|
|
1124
|
-
if (lodash.isEmpty(seoData) && lodash.isEmpty(customSeo)) return;
|
|
1125
1076
|
|
|
1126
1077
|
const { "meta-title": metaTitle, "meta-description": metaDescription, "meta-keywords": keywords } = seoData;
|
|
1127
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,14 +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
|
-
const fallbackSocialImage = get(seoConfig, ["fallbackSocialImage"]);
|
|
124
115
|
|
|
125
116
|
if (!image) {
|
|
126
117
|
return [];
|
|
@@ -131,55 +122,18 @@ export function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
|
|
|
131
122
|
if (pageType == "story-page") {
|
|
132
123
|
tags.push({ name: "robots", content: "max-image-preview:large" });
|
|
133
124
|
}
|
|
134
|
-
const getHeroImage = (imageRatio, imageProp) => {
|
|
135
|
-
return includesHost ? image : `https://${imageCdnUrl}/${image.path(imageRatio, imageProp)}`;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const getWatermarkHeroImage = (imageRatio, imageProp) => {
|
|
139
|
-
const overlayWatermarkProps = Object.assign({}, imageProp, {
|
|
140
|
-
overlay: getWatermarkImage(story, imageCdnSrc, imageCdnUrl),
|
|
141
|
-
overlay_position: "bottom",
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
const watermarkImageProps =
|
|
145
|
-
imageCdnSrc && imageCdnSrc.includes("gumlet")
|
|
146
|
-
? Object.assign({}, overlayWatermarkProps, {
|
|
147
|
-
overlay_width_pct: 1,
|
|
148
|
-
})
|
|
149
|
-
: Object.assign({}, overlayWatermarkProps, {
|
|
150
|
-
overlay_width: 100,
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
const getFallbackImage = () => {
|
|
154
|
-
if (fallbackSocialImage) {
|
|
155
|
-
const fbUrl = new URL(fallbackSocialImage);
|
|
156
|
-
const fbImageSlug = new FocusedImage(fbUrl.href.slice(fbUrl.origin.length + 1));
|
|
157
|
-
const fbHost = new URL(fallbackSocialImage).origin;
|
|
158
|
-
return `${fbHost}/${fbImageSlug.path(imageRatio, watermarkImageProps)}`;
|
|
159
|
-
} else {
|
|
160
|
-
return image;
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
return includesHost ? getFallbackImage() : `https://${imageCdnUrl}/${image.path(imageRatio, watermarkImageProps)}`;
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
const getImageContent = (imageRatio) => {
|
|
168
|
-
const imageProp = {
|
|
169
|
-
w: 1200,
|
|
170
|
-
ar: imageRatio.join(":"),
|
|
171
|
-
auto: "format,compress",
|
|
172
|
-
ogImage: true,
|
|
173
|
-
mode: "crop",
|
|
174
|
-
enlarge: true,
|
|
175
|
-
};
|
|
176
|
-
return isWatermarkDisabled ? getHeroImage(imageRatio, imageProp) : getWatermarkHeroImage(imageRatio, imageProp);
|
|
177
|
-
};
|
|
178
125
|
|
|
179
126
|
if (seoConfig.enableTwitterCards) {
|
|
180
127
|
tags.push({
|
|
181
128
|
name: "twitter:image",
|
|
182
|
-
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
|
+
})}`,
|
|
183
137
|
});
|
|
184
138
|
alt && tags.push({ property: "twitter:image:alt", content: alt });
|
|
185
139
|
}
|
|
@@ -187,7 +141,14 @@ export function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
|
|
|
187
141
|
if (seoConfig.enableOgTags) {
|
|
188
142
|
tags.push({
|
|
189
143
|
property: "og:image",
|
|
190
|
-
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
|
+
})}`,
|
|
191
152
|
});
|
|
192
153
|
tags.push({ property: "og:image:width", content: 1200 });
|
|
193
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);
|