@quintype/seo 1.40.6 → 1.40.7-amphtml-issue.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 +0 -10
- package/dist/index.cjs.js +5 -34
- package/package.json +1 -1
- package/src/amp-tags.js +3 -1
- package/src/image-tags.js +0 -2
- package/src/text-tags.js +0 -32
- package/test/amp_tags_test.js +6 -0
- package/test/image_tags_test.js +227 -127
package/CHANGELOG.md
CHANGED
|
@@ -2,16 +2,6 @@
|
|
|
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.6](https://github.com/quintype/quintype-node-seo/compare/v1.40.5...v1.40.6) (2022-07-11)
|
|
6
|
-
|
|
7
|
-
### [1.40.5](https://github.com/quintype/quintype-node-seo/compare/v1.40.1...v1.40.5) (2022-06-30)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
### Bug Fixes
|
|
11
|
-
|
|
12
|
-
* og image for stories with no image | fallback og image ([454aef9](https://github.com/quintype/quintype-node-seo/commit/454aef9e0a1bc5acfde1aa56d223c518255376a2))
|
|
13
|
-
* Update image schema ([#522](https://github.com/quintype/quintype-node-seo/issues/522)) ([5e42cdc](https://github.com/quintype/quintype-node-seo/commit/5e42cdcbb14d587251b7a3f932a4f98dd358f188))
|
|
14
|
-
|
|
15
5
|
### [1.40.4](https://github.com/quintype/quintype-node-seo/compare/v1.40.4-amptag.0...v1.40.4) (2022-03-22)
|
|
16
6
|
|
|
17
7
|
### [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,33 +159,6 @@ 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
|
-
|
|
189
162
|
// The findRelevantConfig method call has no ownerId for home page.
|
|
190
163
|
// This causes the seoMetadata to be undefined.
|
|
191
164
|
// So the default value for the ownerId is set to null.
|
|
@@ -242,8 +215,6 @@ function getSeoData(config, pageType, data, url = {}, seoConfig = {}) {
|
|
|
242
215
|
return buildTagsFromStory(config, lodash.get(data, ["data", "story"]), url, data) || getSeoData(config, "home-page", data, url);
|
|
243
216
|
case "author-page":
|
|
244
217
|
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);
|
|
247
218
|
case "shell":
|
|
248
219
|
return getShellSeoData(config);
|
|
249
220
|
default:
|
|
@@ -496,8 +467,7 @@ function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
|
|
|
496
467
|
content: includesHost ? image : `https://${config["cdn-image"]}/${image.path([16, 9], {
|
|
497
468
|
w: 1200,
|
|
498
469
|
auto: "format,compress",
|
|
499
|
-
ogImage: true
|
|
500
|
-
enlarge: true
|
|
470
|
+
ogImage: true
|
|
501
471
|
})}`
|
|
502
472
|
});
|
|
503
473
|
alt && tags.push({ property: "twitter:image:alt", content: alt });
|
|
@@ -509,8 +479,7 @@ function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
|
|
|
509
479
|
content: includesHost ? image : `https://${config["cdn-image"]}/${image.path([40, 21], {
|
|
510
480
|
w: 1200,
|
|
511
481
|
auto: "format,compress",
|
|
512
|
-
ogImage: true
|
|
513
|
-
enlarge: true
|
|
482
|
+
ogImage: true
|
|
514
483
|
})}`
|
|
515
484
|
});
|
|
516
485
|
tags.push({ property: "og:image:width", content: 1200 });
|
|
@@ -1090,11 +1059,13 @@ function StoryAmpTags(seoConfig, config, pageType, data = {}, opts) {
|
|
|
1090
1059
|
// TODO: Remove this condition and always make absolute URL if that's better for AMP discoverability.
|
|
1091
1060
|
const ampUrlAppend = seoConfig.appendHostToAmpUrl ? getDomain(currentHostUrl, domainSlug) || config['sketches-host'] : '';
|
|
1092
1061
|
const storySlug = seoConfig.decodeAmpUrl ? decodeURIComponent(story.slug) : encodeURIComponent(story.slug);
|
|
1062
|
+
const ampUrl = story["story-template"] === "visual-story" ? `${ampUrlAppend}/${storySlug}` : `${ampUrlAppend}/amp/story/${storySlug}`;
|
|
1063
|
+
|
|
1093
1064
|
if (showAmpTag(seoConfig, pageType, story)) {
|
|
1094
1065
|
return [{
|
|
1095
1066
|
tag: 'link',
|
|
1096
1067
|
rel: 'amphtml',
|
|
1097
|
-
href:
|
|
1068
|
+
href: ampUrl
|
|
1098
1069
|
}];
|
|
1099
1070
|
} else {
|
|
1100
1071
|
return [];
|
package/package.json
CHANGED
package/src/amp-tags.js
CHANGED
|
@@ -40,11 +40,13 @@ export function StoryAmpTags(seoConfig, config, pageType, data = {}, opts) {
|
|
|
40
40
|
// TODO: Remove this condition and always make absolute URL if that's better for AMP discoverability.
|
|
41
41
|
const ampUrlAppend = seoConfig.appendHostToAmpUrl ? getDomain(currentHostUrl, domainSlug) || config['sketches-host'] : '';
|
|
42
42
|
const storySlug = seoConfig.decodeAmpUrl ? decodeURIComponent(story.slug): encodeURIComponent(story.slug);
|
|
43
|
+
const ampUrl = story["story-template"] === "visual-story" ? `${ampUrlAppend}/${storySlug}` : `${ampUrlAppend}/amp/story/${storySlug}`;
|
|
44
|
+
|
|
43
45
|
if (showAmpTag(seoConfig, pageType, story)) {
|
|
44
46
|
return [{
|
|
45
47
|
tag: 'link',
|
|
46
48
|
rel: 'amphtml',
|
|
47
|
-
href:
|
|
49
|
+
href: ampUrl
|
|
48
50
|
}];
|
|
49
51
|
} else {
|
|
50
52
|
return [];
|
package/src/image-tags.js
CHANGED
|
@@ -128,7 +128,6 @@ export function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
|
|
|
128
128
|
w: 1200,
|
|
129
129
|
auto: "format,compress",
|
|
130
130
|
ogImage: true,
|
|
131
|
-
enlarge: true,
|
|
132
131
|
})}`,
|
|
133
132
|
});
|
|
134
133
|
alt && tags.push({ property: "twitter:image:alt", content: alt });
|
|
@@ -143,7 +142,6 @@ export function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
|
|
|
143
142
|
w: 1200,
|
|
144
143
|
auto: "format,compress",
|
|
145
144
|
ogImage: true,
|
|
146
|
-
enlarge: true,
|
|
147
145
|
})}`,
|
|
148
146
|
});
|
|
149
147
|
tags.push({ property: "og:image:width", content: 1200 });
|
package/src/text-tags.js
CHANGED
|
@@ -112,33 +112,6 @@ 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
|
-
|
|
142
115
|
// The findRelevantConfig method call has no ownerId for home page.
|
|
143
116
|
// This causes the seoMetadata to be undefined.
|
|
144
117
|
// So the default value for the ownerId is set to null.
|
|
@@ -215,11 +188,6 @@ function getSeoData(config, pageType, data, url = {}, seoConfig = {}) {
|
|
|
215
188
|
buildTagsFromAuthor(config, get(data, ["data", "author"], {}), url, data) ||
|
|
216
189
|
getSeoData(config, "home-page", data, url)
|
|
217
190
|
);
|
|
218
|
-
case "static-page":
|
|
219
|
-
return (
|
|
220
|
-
buildTagsFromStaticPage(config, get(data, ["data", "page"], {}), url, data) ||
|
|
221
|
-
getSeoData(config, "home-page", data, url)
|
|
222
|
-
);
|
|
223
191
|
case "shell":
|
|
224
192
|
return getShellSeoData(config);
|
|
225
193
|
default:
|
package/test/amp_tags_test.js
CHANGED
|
@@ -19,6 +19,12 @@ describe('AmpTags', function () {
|
|
|
19
19
|
assertContains('<link rel="amphtml" href="/amp/story/section%2Fslug"/>', string);
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
+
it("it does not append `/amp/story` to the amp tag when it's a visual story", function () {
|
|
23
|
+
const story = { slug: "section/slug", "is-amp-supported": true };
|
|
24
|
+
const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: { ...story, "story-template": "visual-story" } } }, {});
|
|
25
|
+
assertContains('<link rel="amphtml" href="/section%2Fslug"/>', string);
|
|
26
|
+
});
|
|
27
|
+
|
|
22
28
|
it("does not rely on is-amp-supported in story API", function () {
|
|
23
29
|
const story = { slug: "section/slug", "is-amp-supported": false };
|
|
24
30
|
const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, {});
|
package/test/image_tags_test.js
CHANGED
|
@@ -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,39 +22,51 @@ 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
|
-
|
|
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
|
+
);
|
|
41
53
|
assertContains(
|
|
42
|
-
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?w=1200&auto=format%2Ccompress&ogImage=true
|
|
54
|
+
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?w=1200&auto=format%2Ccompress&ogImage=true"/>',
|
|
43
55
|
string
|
|
44
56
|
);
|
|
45
57
|
assertContains(
|
|
46
|
-
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?w=1200&auto=format%2Ccompress&ogImage=true
|
|
58
|
+
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?w=1200&auto=format%2Ccompress&ogImage=true"/>',
|
|
47
59
|
ampPageString
|
|
48
60
|
);
|
|
49
61
|
});
|
|
50
62
|
|
|
51
|
-
it("has facebook tags resized correctly", function
|
|
63
|
+
it("has facebook tags resized correctly", function() {
|
|
52
64
|
const story = {
|
|
53
65
|
"hero-image-s3-key": "my/images.png",
|
|
54
66
|
"hero-image-metadata": {
|
|
55
67
|
width: 2400,
|
|
56
68
|
height: 1260,
|
|
57
|
-
"focus-point": [0, 0]
|
|
69
|
+
"focus-point": [0, 0]
|
|
58
70
|
},
|
|
59
71
|
alternative: {
|
|
60
72
|
social: {
|
|
@@ -64,11 +76,11 @@ describe("ImageTags", function () {
|
|
|
64
76
|
"hero-image-metadata": {
|
|
65
77
|
width: 2400,
|
|
66
78
|
height: 1260,
|
|
67
|
-
"focus-point": [0, 0]
|
|
79
|
+
"focus-point": [0, 0]
|
|
68
80
|
},
|
|
69
|
-
"hero-image-s3-key": "my/socialimage.png"
|
|
70
|
-
}
|
|
71
|
-
}
|
|
81
|
+
"hero-image-s3-key": "my/socialimage.png"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
72
84
|
},
|
|
73
85
|
home: {
|
|
74
86
|
default: {
|
|
@@ -77,22 +89,34 @@ describe("ImageTags", function () {
|
|
|
77
89
|
"hero-image-metadata": {
|
|
78
90
|
width: 2400,
|
|
79
91
|
height: 1260,
|
|
80
|
-
"focus-point": [0, 0]
|
|
92
|
+
"focus-point": [0, 0]
|
|
81
93
|
},
|
|
82
|
-
"hero-image-s3-key": "my/homeimage.png"
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
94
|
+
"hero-image-s3-key": "my/homeimage.png"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
87
99
|
};
|
|
88
|
-
const string = getSeoMetadata(
|
|
89
|
-
|
|
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
|
+
);
|
|
90
114
|
assertContains(
|
|
91
|
-
'<meta property="og:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?rect=0%2C0%2C2400%2C1260&w=1200&auto=format%2Ccompress&ogImage=true
|
|
115
|
+
'<meta property="og:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?rect=0%2C0%2C2400%2C1260&w=1200&auto=format%2Ccompress&ogImage=true"/>',
|
|
92
116
|
string
|
|
93
117
|
);
|
|
94
118
|
assertContains(
|
|
95
|
-
'<meta property="og:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?rect=0%2C0%2C2400%2C1260&w=1200&auto=format%2Ccompress&ogImage=true
|
|
119
|
+
'<meta property="og:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?rect=0%2C0%2C2400%2C1260&w=1200&auto=format%2Ccompress&ogImage=true"/>',
|
|
96
120
|
ampPageString
|
|
97
121
|
);
|
|
98
122
|
assertContains('<meta property="og:image:width" content="1200"/>', string);
|
|
@@ -101,7 +125,7 @@ describe("ImageTags", function () {
|
|
|
101
125
|
assertContains('<meta property="og:image:height" content="630"/>', ampPageString);
|
|
102
126
|
});
|
|
103
127
|
|
|
104
|
-
it("gets card image values instead of story image values on card share", function
|
|
128
|
+
it("gets card image values instead of story image values on card share", function() {
|
|
105
129
|
const story = {
|
|
106
130
|
"hero-image-s3-key": "my/image.png",
|
|
107
131
|
cards: [
|
|
@@ -116,32 +140,38 @@ describe("ImageTags", function () {
|
|
|
116
140
|
metadata: {
|
|
117
141
|
width: 1300,
|
|
118
142
|
height: 1065,
|
|
119
|
-
"mime-type": "image/jpeg"
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
]
|
|
143
|
+
"mime-type": "image/jpeg"
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
]
|
|
126
150
|
};
|
|
127
151
|
|
|
128
152
|
const opts = {
|
|
129
153
|
url: {
|
|
130
154
|
query: {
|
|
131
|
-
cardId: "sample-card-id"
|
|
132
|
-
}
|
|
133
|
-
}
|
|
155
|
+
cardId: "sample-card-id"
|
|
156
|
+
}
|
|
157
|
+
}
|
|
134
158
|
};
|
|
135
159
|
|
|
136
|
-
const string = getSeoMetadata(
|
|
160
|
+
const string = getSeoMetadata(
|
|
161
|
+
seoConfig,
|
|
162
|
+
config,
|
|
163
|
+
"story-page",
|
|
164
|
+
{ data: { story: story } },
|
|
165
|
+
opts
|
|
166
|
+
);
|
|
137
167
|
|
|
138
168
|
assertContains(
|
|
139
|
-
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fcard%2Fimage.jpg?w=1200&auto=format%2Ccompress&ogImage=true
|
|
169
|
+
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fcard%2Fimage.jpg?w=1200&auto=format%2Ccompress&ogImage=true"/>',
|
|
140
170
|
string
|
|
141
171
|
);
|
|
142
172
|
});
|
|
143
173
|
|
|
144
|
-
it("gets story hero image attribution values instead of card attribution values on story share", function
|
|
174
|
+
it("gets story hero image attribution values instead of card attribution values on story share", function() {
|
|
145
175
|
const story = {
|
|
146
176
|
"hero-image-s3-key": "my/image.png",
|
|
147
177
|
"hero-image-attribution": "attribution test",
|
|
@@ -158,25 +188,32 @@ describe("ImageTags", function () {
|
|
|
158
188
|
metadata: {
|
|
159
189
|
width: 1300,
|
|
160
190
|
height: 1065,
|
|
161
|
-
"mime-type": "image/jpeg"
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
]
|
|
191
|
+
"mime-type": "image/jpeg"
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
]
|
|
168
198
|
};
|
|
169
199
|
|
|
170
200
|
const opts = {};
|
|
171
201
|
|
|
172
|
-
const string = getSeoMetadata(
|
|
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)
|
|
173
211
|
|
|
174
|
-
assertContains('<meta property="
|
|
212
|
+
assertContains('<meta property="og:image:alt" content="attribution test"/>', string)
|
|
175
213
|
|
|
176
|
-
assertContains('<meta property="og:image:alt" content="attribution test"/>', string);
|
|
177
214
|
});
|
|
178
215
|
|
|
179
|
-
it("gets story summary as attribution if hero image attribution is not present", function
|
|
216
|
+
it("gets story summary as attribution if hero image attribution is not present", function() {
|
|
180
217
|
const story = {
|
|
181
218
|
"hero-image-s3-key": "my/image.png",
|
|
182
219
|
"hero-image-attribution": null,
|
|
@@ -193,25 +230,32 @@ describe("ImageTags", function () {
|
|
|
193
230
|
metadata: {
|
|
194
231
|
width: 1300,
|
|
195
232
|
height: 1065,
|
|
196
|
-
"mime-type": "image/jpeg"
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
]
|
|
233
|
+
"mime-type": "image/jpeg"
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
]
|
|
203
240
|
};
|
|
204
241
|
|
|
205
242
|
const opts = {};
|
|
206
243
|
|
|
207
|
-
const string = getSeoMetadata(
|
|
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)
|
|
208
253
|
|
|
209
|
-
assertContains('<meta property="
|
|
254
|
+
assertContains('<meta property="og:image:alt" content="attribution test"/>', string)
|
|
210
255
|
|
|
211
|
-
assertContains('<meta property="og:image:alt" content="attribution test"/>', string);
|
|
212
256
|
});
|
|
213
257
|
|
|
214
|
-
it("gets story headline as attribution if hero image attribution and summary is not present", function
|
|
258
|
+
it("gets story headline as attribution if hero image attribution and summary is not present", function() {
|
|
215
259
|
const story = {
|
|
216
260
|
"hero-image-s3-key": "my/image.png",
|
|
217
261
|
"hero-image-attribution": null,
|
|
@@ -229,25 +273,32 @@ describe("ImageTags", function () {
|
|
|
229
273
|
metadata: {
|
|
230
274
|
width: 1300,
|
|
231
275
|
height: 1065,
|
|
232
|
-
"mime-type": "image/jpeg"
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
]
|
|
276
|
+
"mime-type": "image/jpeg"
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
]
|
|
239
283
|
};
|
|
240
284
|
|
|
241
285
|
const opts = {};
|
|
242
286
|
|
|
243
|
-
const string = getSeoMetadata(
|
|
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)
|
|
244
296
|
|
|
245
|
-
assertContains('<meta property="
|
|
297
|
+
assertContains('<meta property="og:image:alt" content="attribution test"/>', string)
|
|
246
298
|
|
|
247
|
-
assertContains('<meta property="og:image:alt" content="attribution test"/>', string);
|
|
248
299
|
});
|
|
249
300
|
|
|
250
|
-
it("gets card image attribution values instead of story attribution values on card share", function
|
|
301
|
+
it("gets card image attribution values instead of story attribution values on card share", function() {
|
|
251
302
|
const story = {
|
|
252
303
|
"hero-image-s3-key": "my/image.png",
|
|
253
304
|
headline: "story headline",
|
|
@@ -264,31 +315,38 @@ describe("ImageTags", function () {
|
|
|
264
315
|
metadata: {
|
|
265
316
|
width: 1300,
|
|
266
317
|
height: 1065,
|
|
267
|
-
"mime-type": "image/jpeg"
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
]
|
|
318
|
+
"mime-type": "image/jpeg"
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
]
|
|
274
325
|
};
|
|
275
326
|
|
|
276
327
|
const opts = {
|
|
277
328
|
url: {
|
|
278
329
|
query: {
|
|
279
|
-
cardId: "sample-card-id"
|
|
280
|
-
}
|
|
281
|
-
}
|
|
330
|
+
cardId: "sample-card-id"
|
|
331
|
+
}
|
|
332
|
+
}
|
|
282
333
|
};
|
|
283
334
|
|
|
284
|
-
const string = getSeoMetadata(
|
|
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)
|
|
285
344
|
|
|
286
|
-
assertContains('<meta property="
|
|
345
|
+
assertContains('<meta property="og:image:alt" content="attribution test"/>', string)
|
|
287
346
|
|
|
288
|
-
assertContains('<meta property="og:image:alt" content="attribution test"/>', string);
|
|
289
347
|
});
|
|
290
348
|
|
|
291
|
-
it("gets story data as fallback if the card metadata is falsy", function
|
|
349
|
+
it("gets story data as fallback if the card metadata is falsy", function() {
|
|
292
350
|
const story = {
|
|
293
351
|
"hero-image-s3-key": "my/image.png",
|
|
294
352
|
cards: [
|
|
@@ -297,36 +355,48 @@ describe("ImageTags", function () {
|
|
|
297
355
|
metadata: {
|
|
298
356
|
"social-share": {
|
|
299
357
|
title: "share-card-title",
|
|
300
|
-
message: "share-card-description"
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
]
|
|
358
|
+
message: "share-card-description"
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
]
|
|
305
363
|
};
|
|
306
364
|
|
|
307
365
|
const opts = {
|
|
308
366
|
url: {
|
|
309
367
|
query: {
|
|
310
|
-
cardId: "sample-card-id"
|
|
311
|
-
}
|
|
312
|
-
}
|
|
368
|
+
cardId: "sample-card-id"
|
|
369
|
+
}
|
|
370
|
+
}
|
|
313
371
|
};
|
|
314
372
|
|
|
315
|
-
const string = getSeoMetadata(
|
|
316
|
-
|
|
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
|
+
);
|
|
317
387
|
|
|
318
388
|
assertContains(
|
|
319
|
-
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fimage.png?w=1200&auto=format%2Ccompress&ogImage=true
|
|
389
|
+
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fimage.png?w=1200&auto=format%2Ccompress&ogImage=true"/>',
|
|
320
390
|
string
|
|
321
391
|
);
|
|
322
392
|
assertContains(
|
|
323
|
-
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fimage.png?w=1200&auto=format%2Ccompress&ogImage=true
|
|
393
|
+
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fimage.png?w=1200&auto=format%2Ccompress&ogImage=true"/>',
|
|
324
394
|
ampPageString
|
|
325
395
|
);
|
|
326
396
|
});
|
|
327
397
|
|
|
328
|
-
describe("for collection pages", function
|
|
329
|
-
it("pulls images from the collection if present", function
|
|
398
|
+
describe("for collection pages", function() {
|
|
399
|
+
it("pulls images from the collection if present", function() {
|
|
330
400
|
const collection = {
|
|
331
401
|
metadata: {
|
|
332
402
|
"cover-image": {
|
|
@@ -334,21 +404,33 @@ describe("ImageTags", function () {
|
|
|
334
404
|
"cover-image-metadata": {
|
|
335
405
|
width: 2400,
|
|
336
406
|
height: 1260,
|
|
337
|
-
"focus-point": [0, 0]
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
}
|
|
407
|
+
"focus-point": [0, 0]
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
341
411
|
};
|
|
342
|
-
const string = getSeoMetadata(
|
|
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&w=1200&auto=format%2Ccompress&ogImage=true"/>',
|
|
421
|
+
string
|
|
422
|
+
);
|
|
343
423
|
assertContains(
|
|
344
|
-
'<meta property="og:image" content="
|
|
424
|
+
'<meta property="og:image:width" content="1200"/>',
|
|
425
|
+
string
|
|
426
|
+
);
|
|
427
|
+
assertContains(
|
|
428
|
+
'<meta property="og:image:height" content="630"/>',
|
|
345
429
|
string
|
|
346
430
|
);
|
|
347
|
-
assertContains('<meta property="og:image:width" content="1200"/>', string);
|
|
348
|
-
assertContains('<meta property="og:image:height" content="630"/>', string);
|
|
349
431
|
});
|
|
350
432
|
|
|
351
|
-
it("pulls images with alt from the collection if present", function
|
|
433
|
+
it("pulls images with alt from the collection if present", function() {
|
|
352
434
|
const collection = {
|
|
353
435
|
name: "collection name",
|
|
354
436
|
summary: "collection summary",
|
|
@@ -358,23 +440,41 @@ describe("ImageTags", function () {
|
|
|
358
440
|
"cover-image-metadata": {
|
|
359
441
|
width: 2400,
|
|
360
442
|
height: 1260,
|
|
361
|
-
"focus-point": [0, 0]
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}
|
|
443
|
+
"focus-point": [0, 0]
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
365
447
|
};
|
|
366
|
-
const string = getSeoMetadata(
|
|
367
|
-
|
|
368
|
-
|
|
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
|
+
);
|
|
369
463
|
});
|
|
370
464
|
|
|
371
|
-
it("does not add tags if the cover image is missing", function
|
|
465
|
+
it("does not add tags if the cover image is missing", function() {
|
|
372
466
|
const collection = {
|
|
373
467
|
metadata: {
|
|
374
|
-
"cover-image": {}
|
|
375
|
-
}
|
|
468
|
+
"cover-image": {}
|
|
469
|
+
}
|
|
376
470
|
};
|
|
377
|
-
const string = getSeoMetadata(
|
|
471
|
+
const string = getSeoMetadata(
|
|
472
|
+
seoConfig,
|
|
473
|
+
config,
|
|
474
|
+
"home-page",
|
|
475
|
+
{ data: { collection: collection } },
|
|
476
|
+
{}
|
|
477
|
+
);
|
|
378
478
|
assert.equal("", string);
|
|
379
479
|
});
|
|
380
480
|
});
|