@quintype/seo 1.40.6-embed-url.3 → 1.40.6-og-image.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/.vscode/settings.json +1 -0
- package/dist/index.cjs.js +5 -26
- package/package.json +1 -1
- package/src/image-tags.js +2 -0
- package/src/structured-data/structured-data-tags.js +5 -26
- package/test/image_tags_test.js +127 -227
package/.vscode/settings.json
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -496,7 +496,8 @@ function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
|
|
|
496
496
|
content: includesHost ? image : `https://${config["cdn-image"]}/${image.path([16, 9], {
|
|
497
497
|
w: 1200,
|
|
498
498
|
auto: "format,compress",
|
|
499
|
-
ogImage: true
|
|
499
|
+
ogImage: true,
|
|
500
|
+
enlarge: true
|
|
500
501
|
})}`
|
|
501
502
|
});
|
|
502
503
|
alt && tags.push({ property: "twitter:image:alt", content: alt });
|
|
@@ -508,7 +509,8 @@ function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
|
|
|
508
509
|
content: includesHost ? image : `https://${config["cdn-image"]}/${image.path([40, 21], {
|
|
509
510
|
w: 1200,
|
|
510
511
|
auto: "format,compress",
|
|
511
|
-
ogImage: true
|
|
512
|
+
ogImage: true,
|
|
513
|
+
enlarge: true
|
|
512
514
|
})}`
|
|
513
515
|
});
|
|
514
516
|
tags.push({ property: "og:image:width", content: 1200 });
|
|
@@ -820,32 +822,9 @@ function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherC
|
|
|
820
822
|
};
|
|
821
823
|
}
|
|
822
824
|
|
|
823
|
-
function getEmbedUrl(cards) {
|
|
824
|
-
// get the first story element which has the embed url
|
|
825
|
-
|
|
826
|
-
let storyElemIndex;
|
|
827
|
-
|
|
828
|
-
const card = cards.find(card => {
|
|
829
|
-
const storyElements = card["story-elements"];
|
|
830
|
-
return storyElements.find((elem, index) => {
|
|
831
|
-
if (elem["embed-url"]) {
|
|
832
|
-
storyElemIndex = index;
|
|
833
|
-
return elem["embed-url"];
|
|
834
|
-
}
|
|
835
|
-
return false;
|
|
836
|
-
});
|
|
837
|
-
});
|
|
838
|
-
if (card) {
|
|
839
|
-
const storyElement = card['story-elements'][storyElemIndex];
|
|
840
|
-
return storyElement["embed-url"];
|
|
841
|
-
}
|
|
842
|
-
return "";
|
|
843
|
-
}
|
|
844
|
-
|
|
845
825
|
function generateVideoArticleData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
|
|
846
826
|
const metaKeywords = story.seo && story.seo["meta-keywords"] || [];
|
|
847
|
-
const
|
|
848
|
-
const embedUrl = getEmbedUrl(storyCards);
|
|
827
|
+
const embedUrl = get__default["default"](story, ["cards", "0", "story-elements", "0", "embed-url"], "");
|
|
849
828
|
const socialShareMsg = get__default["default"](story, ["summary"], "");
|
|
850
829
|
const metaDescription = get__default["default"](story, ["seo", "meta-description"], "");
|
|
851
830
|
const subHeadline = get__default["default"](story, ["subheadline"], "");
|
package/package.json
CHANGED
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 });
|
|
@@ -254,33 +254,9 @@ function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherC
|
|
|
254
254
|
};
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
-
function getEmbedUrl(cards) {
|
|
258
|
-
// get the first story element which has the embed url
|
|
259
|
-
|
|
260
|
-
let storyElemIndex;
|
|
261
|
-
|
|
262
|
-
const card = cards.find((card) => {
|
|
263
|
-
const storyElements = card["story-elements"];
|
|
264
|
-
return storyElements.find((elem, index) => {
|
|
265
|
-
if (elem["embed-url"]) {
|
|
266
|
-
storyElemIndex = index;
|
|
267
|
-
return elem["embed-url"];
|
|
268
|
-
}
|
|
269
|
-
return false;
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
if (card) {
|
|
273
|
-
const storyElement = card['story-elements'][storyElemIndex]
|
|
274
|
-
return storyElement["embed-url"];
|
|
275
|
-
}
|
|
276
|
-
return "";
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
|
|
280
257
|
function generateVideoArticleData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
|
|
281
258
|
const metaKeywords = (story.seo && story.seo["meta-keywords"]) || [];
|
|
282
|
-
const
|
|
283
|
-
const embedUrl = getEmbedUrl(storyCards);
|
|
259
|
+
const embedUrl = get(story, ["cards", "0", "story-elements", "0", "embed-url"], "");
|
|
284
260
|
const socialShareMsg = get(story, ["summary"], "");
|
|
285
261
|
const metaDescription = get(story, ["seo", "meta-description"], "");
|
|
286
262
|
const subHeadline = get(story, ["subheadline"], "");
|
|
@@ -500,7 +476,10 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re
|
|
|
500
476
|
}
|
|
501
477
|
|
|
502
478
|
if (structuredData.enableVideo && story["story-template"] === "video") {
|
|
503
|
-
return ldJson(
|
|
479
|
+
return ldJson(
|
|
480
|
+
"VideoObject",
|
|
481
|
+
generateVideoArticleData(structuredData, story, publisherConfig, timezone)
|
|
482
|
+
);
|
|
504
483
|
}
|
|
505
484
|
|
|
506
485
|
if (structuredData.enableNewsArticle !== "withoutArticleSchema") {
|
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,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
|
-
|
|
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&auto=format%2Ccompress&ogImage=true"/>',
|
|
42
|
+
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?w=1200&auto=format%2Ccompress&ogImage=true&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&auto=format%2Ccompress&ogImage=true"/>',
|
|
46
|
+
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fsocialimage.png?w=1200&auto=format%2Ccompress&ogImage=true&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
|
-
|
|
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&w=1200&auto=format%2Ccompress&ogImage=true"/>',
|
|
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&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&w=1200&auto=format%2Ccompress&ogImage=true"/>',
|
|
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&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&auto=format%2Ccompress&ogImage=true"/>',
|
|
139
|
+
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fcard%2Fimage.jpg?w=1200&auto=format%2Ccompress&ogImage=true&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="
|
|
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="
|
|
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="
|
|
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="
|
|
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
|
-
|
|
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&auto=format%2Ccompress&ogImage=true"/>',
|
|
319
|
+
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fimage.png?w=1200&auto=format%2Ccompress&ogImage=true&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&auto=format%2Ccompress&ogImage=true"/>',
|
|
323
|
+
'<meta name="twitter:image" content="https://thumbor.assettype.com/my%2Fimage.png?w=1200&auto=format%2Ccompress&ogImage=true&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&w=1200&auto=format%2Ccompress&ogImage=true"/>',
|
|
421
|
-
string
|
|
422
|
-
);
|
|
342
|
+
const string = getSeoMetadata(seoConfig, config, "home-page", { data: { collection: collection } }, {});
|
|
423
343
|
assertContains(
|
|
424
|
-
'<meta property="og:image
|
|
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&w=1200&auto=format%2Ccompress&ogImage=true&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
|
-
|
|
450
|
-
|
|
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
|
});
|