@quintype/seo 1.40.5-amphtml-issue.1 → 1.40.5-static-page-seo.2
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/dist/index.cjs.js +87 -60
- package/package.json +1 -1
- package/src/amp-tags.js +1 -3
- package/src/text-tags.js +32 -0
package/dist/index.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var lodash = require('lodash');
|
|
5
|
+
var lodash$1 = require('lodash');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var ReactDomServer = require('react-dom/server');
|
|
8
8
|
var url = require('url');
|
|
@@ -21,7 +21,7 @@ var isUndefined__default = /*#__PURE__*/_interopDefaultLegacy(isUndefined);
|
|
|
21
21
|
var omitBy__default = /*#__PURE__*/_interopDefaultLegacy(omitBy);
|
|
22
22
|
|
|
23
23
|
function objectToTags(object) {
|
|
24
|
-
return lodash.entries(object).filter(([key, value]) => value).map(([key, value]) => ({ [getPropertyName(key)]: key, content: value }));
|
|
24
|
+
return lodash$1.entries(object).filter(([key, value]) => value).map(([key, value]) => ({ [getPropertyName(key)]: key, content: value }));
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
function getPropertyName(key) {
|
|
@@ -56,7 +56,7 @@ function buildTagsFromStory(config, story, url = {}, data = {}) {
|
|
|
56
56
|
const { metadata = {} } = story.cards.find(card => card.id === cardId) || {};
|
|
57
57
|
const urlWithCardId = `${config["sketches-host"]}/${story.slug}?cardId=${cardId}`;
|
|
58
58
|
|
|
59
|
-
if (metadata && !lodash.isEmpty(metadata) && metadata["social-share"]) {
|
|
59
|
+
if (metadata && !lodash$1.isEmpty(metadata) && metadata["social-share"]) {
|
|
60
60
|
return {
|
|
61
61
|
title: metadata["social-share"].title || story.headline,
|
|
62
62
|
description: metadata["social-share"].message || story.summary,
|
|
@@ -72,14 +72,14 @@ function buildTagsFromStory(config, story, url = {}, data = {}) {
|
|
|
72
72
|
|
|
73
73
|
const storyUrl = story.url || `${config["sketches-host"]}/${story.slug}`;
|
|
74
74
|
|
|
75
|
-
const customSeo = lodash.get(data, ["data", "customSeo"], {});
|
|
76
|
-
const authors = lodash.get(story, ["authors"], []).map(author => author.name);
|
|
75
|
+
const customSeo = lodash$1.get(data, ["data", "customSeo"], {});
|
|
76
|
+
const authors = lodash$1.get(story, ["authors"], []).map(author => author.name);
|
|
77
77
|
const title = customSeo.title || seo["meta-title"] || story.headline;
|
|
78
78
|
const pageTitle = customSeo["page-title"] || seo["meta-title"] || story.headline;
|
|
79
79
|
const description = customSeo.description || seo["meta-description"] || story.summary;
|
|
80
80
|
const keywords = (customSeo.keywords || seo["meta-keywords"] || (story.tags || []).map(tag => tag.name)).join(",");
|
|
81
|
-
const ogUrl = customSeo.ogUrl || lodash.get(seo, ["og", "url"]) || storyUrl;
|
|
82
|
-
const getOgTitle = customSeo.ogTitle || lodash.get(story, ["alternative", "social", "default", "headline"], story.headline) || story.headline;
|
|
81
|
+
const ogUrl = customSeo.ogUrl || lodash$1.get(seo, ["og", "url"]) || storyUrl;
|
|
82
|
+
const getOgTitle = customSeo.ogTitle || lodash$1.get(story, ["alternative", "social", "default", "headline"], story.headline) || story.headline;
|
|
83
83
|
const ogDescription = customSeo.ogDescription || story.summary;
|
|
84
84
|
const storyMetaData = {
|
|
85
85
|
title,
|
|
@@ -103,8 +103,8 @@ function buildTagsFromStory(config, story, url = {}, data = {}) {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
function buildTagsFromTopic(config, tag, url = {}, data) {
|
|
106
|
-
if (lodash.isEmpty(tag)) return;
|
|
107
|
-
const customSeo = lodash.get(data, ["data", "customSeo"], {});
|
|
106
|
+
if (lodash$1.isEmpty(tag)) return;
|
|
107
|
+
const customSeo = lodash$1.get(data, ["data", "customSeo"], {});
|
|
108
108
|
const tagName = customSeo.title || tag["meta-title"] || tag.name;
|
|
109
109
|
const pageTitle = customSeo["page-title"] || tagName;
|
|
110
110
|
const tagDescription = customSeo.description || tag["meta-description"];
|
|
@@ -129,9 +129,9 @@ function buildTagsFromTopic(config, tag, url = {}, data) {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
function buildTagsFromAuthor(config, author, url = {}, data) {
|
|
132
|
-
if (lodash.isEmpty(author)) return;
|
|
132
|
+
if (lodash$1.isEmpty(author)) return;
|
|
133
133
|
|
|
134
|
-
const customSeo = lodash.get(data, ["data", "customSeo"], {});
|
|
134
|
+
const customSeo = lodash$1.get(data, ["data", "customSeo"], {});
|
|
135
135
|
const title = customSeo.title || author.name;
|
|
136
136
|
const pageTitle = customSeo["page-title"] || title;
|
|
137
137
|
const description = customSeo.description || author.bio || `View all articles written by ${title}`;
|
|
@@ -159,6 +159,33 @@ function buildCustomTags(customTags = {}, pageType = "") {
|
|
|
159
159
|
return {};
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
function buildTagsFromStaticPage(config, page, url = {}, data) {
|
|
163
|
+
const seoData = lodash$1.get(page, ["metadata", "seo"], {});
|
|
164
|
+
const customSeo = lodash$1.get(data, ["data", "customSeo"], {});
|
|
165
|
+
if (lodash$1.isEmpty(seoData) && lodash$1.isEmpty(customSeo)) return;
|
|
166
|
+
|
|
167
|
+
const { "meta-title": metaTitle, "meta-description": metaDescription, "meta-keywords": keywords } = seoData;
|
|
168
|
+
|
|
169
|
+
const title = customSeo.title || metaTitle || page.title;
|
|
170
|
+
const pageTitle = customSeo["page-title"] || title;
|
|
171
|
+
const description = customSeo.description || metaDescription;
|
|
172
|
+
const ogTitle = customSeo.ogTitle || title;
|
|
173
|
+
const staticPageUrl = `${config["sketches-host"]}${url.pathname}`;
|
|
174
|
+
const ogDescription = customSeo.ogDescription || description;
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
title,
|
|
178
|
+
"page-title": pageTitle,
|
|
179
|
+
description,
|
|
180
|
+
keywords: `${title},${config["publisher-name"]}`,
|
|
181
|
+
canonicalUrl: staticPageUrl,
|
|
182
|
+
ogUrl: staticPageUrl,
|
|
183
|
+
ogTitle,
|
|
184
|
+
ogDescription,
|
|
185
|
+
keywords: customSeo.keywords || keywords
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
162
189
|
// The findRelevantConfig method call has no ownerId for home page.
|
|
163
190
|
// This causes the seoMetadata to be undefined.
|
|
164
191
|
// So the default value for the ownerId is set to null.
|
|
@@ -168,8 +195,8 @@ function getSeoData(config, pageType, data, url = {}, seoConfig = {}) {
|
|
|
168
195
|
const seoMetadata = config["seo-metadata"].find(page => page["owner-type"] === ownerType && page["owner-id"] === ownerId) || {};
|
|
169
196
|
const { sections = [] } = config;
|
|
170
197
|
const section = sections.find(section => ownerType == "section" && section.id === ownerId) || {};
|
|
171
|
-
const customSeo = lodash.get(data, ["data", "customSeo"], {});
|
|
172
|
-
if (seoMetadata.data || section.id || !lodash.isEmpty(customSeo)) {
|
|
198
|
+
const customSeo = lodash$1.get(data, ["data", "customSeo"], {});
|
|
199
|
+
if (seoMetadata.data || section.id || !lodash$1.isEmpty(customSeo)) {
|
|
173
200
|
const result = Object.assign({}, {
|
|
174
201
|
"page-title": customSeo["page-title"] || section.name,
|
|
175
202
|
title: customSeo.title || section.name,
|
|
@@ -202,19 +229,21 @@ function getSeoData(config, pageType, data, url = {}, seoConfig = {}) {
|
|
|
202
229
|
case "home-page":
|
|
203
230
|
return findRelevantConfig("home");
|
|
204
231
|
case "section-page":
|
|
205
|
-
return findRelevantConfig("section", lodash.get(data, ["data", "section", "id"])) || getSeoDataFromCollection(config, data) || getSeoData(config, "home-page", data, url);
|
|
232
|
+
return findRelevantConfig("section", lodash$1.get(data, ["data", "section", "id"])) || getSeoDataFromCollection(config, data) || getSeoData(config, "home-page", data, url);
|
|
206
233
|
case "collection-page":
|
|
207
234
|
return getSeoDataFromCollection(config, data) || getSeoData(config, "home-page", data, url);
|
|
208
235
|
case "tag-page":
|
|
209
|
-
return buildTagsFromTopic(config, lodash.get(data, ["data", "tag"]), url, data) || getSeoData(config, "home-page", data, url);
|
|
236
|
+
return buildTagsFromTopic(config, lodash$1.get(data, ["data", "tag"]), url, data) || getSeoData(config, "home-page", data, url);
|
|
210
237
|
case "story-page":
|
|
211
|
-
return buildTagsFromStory(config, lodash.get(data, ["data", "story"]), url, data) || getSeoData(config, "home-page", data, url);
|
|
238
|
+
return buildTagsFromStory(config, lodash$1.get(data, ["data", "story"]), url, data) || getSeoData(config, "home-page", data, url);
|
|
212
239
|
case "visual-story":
|
|
213
|
-
return buildTagsFromStory(config, lodash.get(data, ["story"]), url, data) || getSeoData(config, "home-page", data, url);
|
|
240
|
+
return buildTagsFromStory(config, lodash$1.get(data, ["story"]), url, data) || getSeoData(config, "home-page", data, url);
|
|
214
241
|
case "story-page-amp":
|
|
215
|
-
return buildTagsFromStory(config, lodash.get(data, ["data", "story"]), url, data) || getSeoData(config, "home-page", data, url);
|
|
242
|
+
return buildTagsFromStory(config, lodash$1.get(data, ["data", "story"]), url, data) || getSeoData(config, "home-page", data, url);
|
|
216
243
|
case "author-page":
|
|
217
|
-
return buildTagsFromAuthor(config, lodash.get(data, ["data", "author"], {}), url, data) || getSeoData(config, "home-page", data, url);
|
|
244
|
+
return buildTagsFromAuthor(config, lodash$1.get(data, ["data", "author"], {}), url, data) || getSeoData(config, "home-page", data, url);
|
|
245
|
+
case "static-page":
|
|
246
|
+
return buildTagsFromStaticPage(config, lodash.get(data, ["data", "page"], {}), url, data) || getSeoData(config, "home-page", data, url);
|
|
218
247
|
case "shell":
|
|
219
248
|
return getShellSeoData(config);
|
|
220
249
|
default:
|
|
@@ -223,9 +252,9 @@ function getSeoData(config, pageType, data, url = {}, seoConfig = {}) {
|
|
|
223
252
|
}
|
|
224
253
|
|
|
225
254
|
function getSeoDataFromCollection(config, data) {
|
|
226
|
-
if (lodash.get(data, ["data", "collection", "name"])) {
|
|
227
|
-
let { name, summary } = lodash.get(data, ["data", "collection"]);
|
|
228
|
-
const customSeo = lodash.get(data, ["data", "customSeo"], {});
|
|
255
|
+
if (lodash$1.get(data, ["data", "collection", "name"])) {
|
|
256
|
+
let { name, summary } = lodash$1.get(data, ["data", "collection"]);
|
|
257
|
+
const customSeo = lodash$1.get(data, ["data", "customSeo"], {});
|
|
229
258
|
|
|
230
259
|
if (!summary) {
|
|
231
260
|
summary = (getSeoData(config, "home-page", data) || {}).description;
|
|
@@ -266,7 +295,7 @@ const SKIP_CANONICAL = "__SKIP__CANONICAL__";
|
|
|
266
295
|
*/
|
|
267
296
|
function TextTags(seoConfig, config, pageType, data, { url }) {
|
|
268
297
|
const seoData = getSeoData(config, pageType, data, url, seoConfig);
|
|
269
|
-
const customSeo = lodash.get(data, ["data", "customSeo"], {});
|
|
298
|
+
const customSeo = lodash$1.get(data, ["data", "customSeo"], {});
|
|
270
299
|
|
|
271
300
|
if (!seoData) return [];
|
|
272
301
|
|
|
@@ -307,18 +336,18 @@ function TextTags(seoConfig, config, pageType, data, { url }) {
|
|
|
307
336
|
|
|
308
337
|
if ((pageType === "story-page" || pageType === "story-page-amp") && seoConfig.enableNews) {
|
|
309
338
|
commonTags.push({ name: "news_keywords", content: seoData.keywords });
|
|
310
|
-
if (lodash.get(data, ["data", "story", "seo", "meta-google-news-standout"])) commonTags.push({ tag: "link", rel: "standout", href: seoData.storyUrl || currentUrl });
|
|
339
|
+
if (lodash$1.get(data, ["data", "story", "seo", "meta-google-news-standout"])) commonTags.push({ tag: "link", rel: "standout", href: seoData.storyUrl || currentUrl });
|
|
311
340
|
}
|
|
312
341
|
|
|
313
342
|
return commonTags.concat(objectToTags(allTags));
|
|
314
343
|
}
|
|
315
344
|
|
|
316
345
|
function getTitle$1(seoConfig, config, pageType, data, params) {
|
|
317
|
-
const customSeo = lodash.get(data, ["data", "customSeo"], {});
|
|
346
|
+
const customSeo = lodash$1.get(data, ["data", "customSeo"], {});
|
|
318
347
|
|
|
319
|
-
if (lodash.get(data, ["title"])) return customSeo.title || lodash.get(data, ["title"]);
|
|
348
|
+
if (lodash$1.get(data, ["title"])) return customSeo.title || lodash$1.get(data, ["title"]);
|
|
320
349
|
|
|
321
|
-
if (lodash.get(data, ["data", "title"])) return customSeo.title || lodash.get(data, ["data", "title"]);
|
|
350
|
+
if (lodash$1.get(data, ["data", "title"])) return customSeo.title || lodash$1.get(data, ["data", "title"]);
|
|
322
351
|
|
|
323
352
|
const seoData = getSeoData(config, pageType, data, undefined, seoConfig) || {};
|
|
324
353
|
return customSeo.title || seoData["page-title"];
|
|
@@ -348,13 +377,13 @@ function AuthorTags(seoConfig, config, pageType, data, { url }) {
|
|
|
348
377
|
|
|
349
378
|
return [{
|
|
350
379
|
name: "twitter:creator",
|
|
351
|
-
content: lodash.get(data, ["data", "story", "author-name"])
|
|
380
|
+
content: lodash$1.get(data, ["data", "story", "author-name"])
|
|
352
381
|
}];
|
|
353
382
|
}
|
|
354
383
|
|
|
355
384
|
function pickImageFromCard(story, cardId) {
|
|
356
385
|
const { metadata = {} } = story.cards.find(card => card.id === cardId) || {};
|
|
357
|
-
if (metadata && !lodash.isEmpty(metadata) && lodash.get(metadata, ["social-share", "image", "key"], false)) {
|
|
386
|
+
if (metadata && !lodash$1.isEmpty(metadata) && lodash$1.get(metadata, ["social-share", "image", "key"], false)) {
|
|
358
387
|
const alt = metadata["social-share"].image.attribution || metadata["social-share"].title || metadata["social-share"].message || getAttribution(story);
|
|
359
388
|
return {
|
|
360
389
|
image: new quintypeJs.FocusedImage(metadata["social-share"].image.key, metadata["social-share"].image.metadata || {}),
|
|
@@ -364,7 +393,7 @@ function pickImageFromCard(story, cardId) {
|
|
|
364
393
|
}
|
|
365
394
|
|
|
366
395
|
function getAttribution(story) {
|
|
367
|
-
return story["hero-image-attribution"] || story.summary || lodash.get(story, ["alternative", "home", "default", "headline"]) || story.headline;
|
|
396
|
+
return story["hero-image-attribution"] || story.summary || lodash$1.get(story, ["alternative", "home", "default", "headline"]) || story.headline;
|
|
368
397
|
}
|
|
369
398
|
|
|
370
399
|
/**
|
|
@@ -379,16 +408,16 @@ function getAttribution(story) {
|
|
|
379
408
|
*/
|
|
380
409
|
function pickImageFromStory({ story, config, seoConfig }) {
|
|
381
410
|
function getAlt(type, key, fallback) {
|
|
382
|
-
return lodash.get(story, ["alternative", `${type}`, "default", "hero-image", `${key}`], fallback);
|
|
411
|
+
return lodash$1.get(story, ["alternative", `${type}`, "default", "hero-image", `${key}`], fallback);
|
|
383
412
|
}
|
|
384
413
|
|
|
385
414
|
const alt = getAttribution(story);
|
|
386
|
-
const fallbackSocialImage = lodash.get(seoConfig, ["fallbackSocialImage"]);
|
|
415
|
+
const fallbackSocialImage = lodash$1.get(seoConfig, ["fallbackSocialImage"]);
|
|
387
416
|
const altHeroImg = getAlt("home", "hero-image-s3-key", null);
|
|
388
417
|
const altSocialHeroImg = getAlt("social", "hero-image-s3-key", null);
|
|
389
|
-
const storyHeroImage = lodash.get(story, ["hero-image-s3-key"]);
|
|
390
|
-
const logo_url = lodash.get(config, ["theme-attributes", "logo_url"]);
|
|
391
|
-
const logo = lodash.get(config, ["theme-attributes", "logo"]);
|
|
418
|
+
const storyHeroImage = lodash$1.get(story, ["hero-image-s3-key"]);
|
|
419
|
+
const logo_url = lodash$1.get(config, ["theme-attributes", "logo_url"]);
|
|
420
|
+
const logo = lodash$1.get(config, ["theme-attributes", "logo"]);
|
|
392
421
|
|
|
393
422
|
if (altSocialHeroImg) {
|
|
394
423
|
const metadata = getAlt("social", "hero-image-metadata", {});
|
|
@@ -397,7 +426,7 @@ function pickImageFromStory({ story, config, seoConfig }) {
|
|
|
397
426
|
const metadata = getAlt("home", "hero-image-metadata", {});
|
|
398
427
|
return { image: new quintypeJs.FocusedImage(altHeroImg, metadata), alt };
|
|
399
428
|
} else if (storyHeroImage) {
|
|
400
|
-
const metadata = lodash.get(story, ["hero-image-metadata"], {});
|
|
429
|
+
const metadata = lodash$1.get(story, ["hero-image-metadata"], {});
|
|
401
430
|
return { image: new quintypeJs.FocusedImage(storyHeroImage, metadata), alt };
|
|
402
431
|
} else if (fallbackSocialImage) {
|
|
403
432
|
return { image: fallbackSocialImage, alt, includesHost: true };
|
|
@@ -411,7 +440,7 @@ function pickImageFromStory({ story, config, seoConfig }) {
|
|
|
411
440
|
}
|
|
412
441
|
|
|
413
442
|
function pickImageFromCollection(collection) {
|
|
414
|
-
const coverImage = lodash.get(collection, ["metadata", "cover-image"]) || {};
|
|
443
|
+
const coverImage = lodash$1.get(collection, ["metadata", "cover-image"]) || {};
|
|
415
444
|
if (!coverImage["cover-image-s3-key"]) return {};
|
|
416
445
|
const alt = collection.summary || collection.name || null;
|
|
417
446
|
return { image: new quintypeJs.FocusedImage(coverImage["cover-image-s3-key"], coverImage["cover-image-metadata"] || {}), alt };
|
|
@@ -420,19 +449,19 @@ function pickImageFromCollection(collection) {
|
|
|
420
449
|
// The image is grabbed from the story, else from from the collection
|
|
421
450
|
function pickImage({ pageType, config, seoConfig, data, url }) {
|
|
422
451
|
if (pageType === "story-page" && url.query && url.query.cardId) {
|
|
423
|
-
const story = lodash.get(data, ["data", "story"]) || {};
|
|
452
|
+
const story = lodash$1.get(data, ["data", "story"]) || {};
|
|
424
453
|
return pickImageFromCard(story, url.query.cardId) || pickImageFromStory({ story, seoConfig, config });
|
|
425
454
|
} else if (pageType === "visual-story" && url.query && url.query.cardId) {
|
|
426
|
-
const story = lodash.get(data, ["story"]) || {};
|
|
455
|
+
const story = lodash$1.get(data, ["story"]) || {};
|
|
427
456
|
return pickImageFromCard(story, url.query.cardId) || pickImageFromStory({ story, seoConfig, config });
|
|
428
457
|
} else if (pageType === "story-page" || pageType === "story-page-amp") {
|
|
429
|
-
const story = lodash.get(data, ["data", "story"]) || {};
|
|
458
|
+
const story = lodash$1.get(data, ["data", "story"]) || {};
|
|
430
459
|
return pickImageFromStory({ story, seoConfig, config });
|
|
431
460
|
} else if (pageType === "visual-story") {
|
|
432
|
-
const story = lodash.get(data, ["story"]) || {};
|
|
461
|
+
const story = lodash$1.get(data, ["story"]) || {};
|
|
433
462
|
return pickImageFromStory({ story, seoConfig, config });
|
|
434
|
-
} else if (lodash.get(data, ["data", "collection"])) {
|
|
435
|
-
return pickImageFromCollection(lodash.get(data, ["data", "collection"]));
|
|
463
|
+
} else if (lodash$1.get(data, ["data", "collection"])) {
|
|
464
|
+
return pickImageFromCollection(lodash$1.get(data, ["data", "collection"]));
|
|
436
465
|
} else {
|
|
437
466
|
return { image: undefined, alt: undefined };
|
|
438
467
|
}
|
|
@@ -483,7 +512,7 @@ function ImageTags(seoConfig, config, pageType, data, { url = {} }) {
|
|
|
483
512
|
})}`
|
|
484
513
|
});
|
|
485
514
|
tags.push({ property: "og:image:width", content: 1200 });
|
|
486
|
-
if (lodash.get(image, ["metadata", "focus-point"])) {
|
|
515
|
+
if (lodash$1.get(image, ["metadata", "focus-point"])) {
|
|
487
516
|
tags.push({ property: "og:image:height", content: 630 });
|
|
488
517
|
}
|
|
489
518
|
alt && tags.push({ property: "og:image:alt", content: alt });
|
|
@@ -519,7 +548,7 @@ function getSchemaHeader({ cssSelector }) {
|
|
|
519
548
|
|
|
520
549
|
function getSchemaBlogPosting(card = {}, author = {}, headline = "", image = "", structuredData = {}, story = {}, timezone) {
|
|
521
550
|
const { website: { url = "" } = {} } = structuredData;
|
|
522
|
-
const orgUrl = lodash.get(structuredData, ["organization", "url"], "");
|
|
551
|
+
const orgUrl = lodash$1.get(structuredData, ["organization", "url"], "");
|
|
523
552
|
return Object.assign({}, getSchemaType("BlogPosting"), getSchemaMainEntityOfPage(`${url}/${story.slug}`), getSchemaPublisher(structuredData.organization, orgUrl), {
|
|
524
553
|
dateModified: stripMillisecondsFromTime(new Date(card["card-updated-at"]), timezone),
|
|
525
554
|
dateCreated: stripMillisecondsFromTime(new Date(card["card-added-at"]), timezone),
|
|
@@ -544,19 +573,19 @@ function getSchemaMainEntityOfPage(id) {
|
|
|
544
573
|
}
|
|
545
574
|
|
|
546
575
|
function getSchemaMovieReview(movieObject = {}) {
|
|
547
|
-
const movieCreatedAt = lodash.get(movieObject, ["created-at"], null);
|
|
548
|
-
const actors = lodash.get(movieObject, ["actors"], []).map(actor => getSchemaPerson(actor.name));
|
|
549
|
-
const directors = lodash.get(movieObject, ["directors"], []).map(director => getSchemaPerson(director.name));
|
|
550
|
-
const producers = lodash.get(movieObject, ["producers"], []).map(producer => getSchemaPerson(producer.name));
|
|
576
|
+
const movieCreatedAt = lodash$1.get(movieObject, ["created-at"], null);
|
|
577
|
+
const actors = lodash$1.get(movieObject, ["actors"], []).map(actor => getSchemaPerson(actor.name));
|
|
578
|
+
const directors = lodash$1.get(movieObject, ["directors"], []).map(director => getSchemaPerson(director.name));
|
|
579
|
+
const producers = lodash$1.get(movieObject, ["producers"], []).map(producer => getSchemaPerson(producer.name));
|
|
551
580
|
|
|
552
581
|
return {
|
|
553
582
|
actors: actors,
|
|
554
583
|
directors: directors,
|
|
555
|
-
name: lodash.get(movieObject, ["name"], ""),
|
|
556
|
-
sameAs: lodash.get(movieObject, ["sameAs"], ""),
|
|
557
|
-
description: lodash.get(movieObject, ["meta-description"], ""),
|
|
584
|
+
name: lodash$1.get(movieObject, ["name"], ""),
|
|
585
|
+
sameAs: lodash$1.get(movieObject, ["sameAs"], ""),
|
|
586
|
+
description: lodash$1.get(movieObject, ["meta-description"], ""),
|
|
558
587
|
producer: producers,
|
|
559
|
-
image: lodash.get(movieObject, ["photo", "0", "url"], ""),
|
|
588
|
+
image: lodash$1.get(movieObject, ["photo", "0", "url"], ""),
|
|
560
589
|
dateCreated: movieCreatedAt ? new Date(movieCreatedAt).toISOString() : ""
|
|
561
590
|
};
|
|
562
591
|
}
|
|
@@ -1059,13 +1088,11 @@ function StoryAmpTags(seoConfig, config, pageType, data = {}, opts) {
|
|
|
1059
1088
|
// TODO: Remove this condition and always make absolute URL if that's better for AMP discoverability.
|
|
1060
1089
|
const ampUrlAppend = seoConfig.appendHostToAmpUrl ? getDomain(currentHostUrl, domainSlug) || config['sketches-host'] : '';
|
|
1061
1090
|
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
|
-
|
|
1064
1091
|
if (showAmpTag(seoConfig, pageType, story)) {
|
|
1065
1092
|
return [{
|
|
1066
1093
|
tag: 'link',
|
|
1067
1094
|
rel: 'amphtml',
|
|
1068
|
-
href:
|
|
1095
|
+
href: `${ampUrlAppend}/amp/story/${storySlug}`
|
|
1069
1096
|
}];
|
|
1070
1097
|
} else {
|
|
1071
1098
|
return [];
|
|
@@ -1166,8 +1193,8 @@ class MetaTagList {
|
|
|
1166
1193
|
}
|
|
1167
1194
|
|
|
1168
1195
|
toString() {
|
|
1169
|
-
const uniqueTags = lodash.uniqBy(this.tags.reverse(), tagToKey).reverse();
|
|
1170
|
-
return ReactDomServer__default["default"].renderToStaticMarkup(uniqueTags.map(tag => React__default["default"].createElement(tag.tag || "meta", lodash.omit(tag, "tag"))));
|
|
1196
|
+
const uniqueTags = lodash$1.uniqBy(this.tags.reverse(), tagToKey).reverse();
|
|
1197
|
+
return ReactDomServer__default["default"].renderToStaticMarkup(uniqueTags.map(tag => React__default["default"].createElement(tag.tag || "meta", lodash$1.omit(tag, "tag"))));
|
|
1171
1198
|
}
|
|
1172
1199
|
|
|
1173
1200
|
addTag() {
|
|
@@ -1236,8 +1263,8 @@ class SEO {
|
|
|
1236
1263
|
}
|
|
1237
1264
|
|
|
1238
1265
|
getMetaTags(config, pageType, data, params = {}) {
|
|
1239
|
-
pageType = lodash.get(this.seoConfig, ["pageTypeAliases", pageType], pageType);
|
|
1240
|
-
return new MetaTagList(lodash.flatMap(this.generators, generator => generator(this.seoConfig, config, pageType, data, params)));
|
|
1266
|
+
pageType = lodash$1.get(this.seoConfig, ["pageTypeAliases", pageType], pageType);
|
|
1267
|
+
return new MetaTagList(lodash$1.flatMap(this.generators, generator => generator(this.seoConfig, config, pageType, data, params)));
|
|
1241
1268
|
}
|
|
1242
1269
|
|
|
1243
1270
|
getTitle(config, pageType, data, params = {}) {
|
package/package.json
CHANGED
package/src/amp-tags.js
CHANGED
|
@@ -40,13 +40,11 @@ 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
|
-
|
|
45
43
|
if (showAmpTag(seoConfig, pageType, story)) {
|
|
46
44
|
return [{
|
|
47
45
|
tag: 'link',
|
|
48
46
|
rel: 'amphtml',
|
|
49
|
-
href:
|
|
47
|
+
href: `${ampUrlAppend}/amp/story/${storySlug}`
|
|
50
48
|
}];
|
|
51
49
|
} else {
|
|
52
50
|
return [];
|
package/src/text-tags.js
CHANGED
|
@@ -112,6 +112,33 @@ function buildCustomTags(customTags = {}, pageType = "") {
|
|
|
112
112
|
return {};
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
function buildTagsFromStaticPage(config, page, url = {}, data) {
|
|
116
|
+
const seoData = get(page, ["metadata", "seo"], {});
|
|
117
|
+
const customSeo = get(data, ["data", "customSeo"], {});
|
|
118
|
+
if (isEmpty(seoData) && isEmpty(customSeo)) return;
|
|
119
|
+
|
|
120
|
+
const { "meta-title": metaTitle, "meta-description": metaDescription, "meta-keywords": keywords } = seoData;
|
|
121
|
+
|
|
122
|
+
const title = customSeo.title || metaTitle || page.title;
|
|
123
|
+
const pageTitle = customSeo["page-title"] || title;
|
|
124
|
+
const description = customSeo.description || metaDescription;
|
|
125
|
+
const ogTitle = customSeo.ogTitle || title;
|
|
126
|
+
const staticPageUrl = `${config["sketches-host"]}${url.pathname}`;
|
|
127
|
+
const ogDescription = customSeo.ogDescription || description;
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
title,
|
|
131
|
+
"page-title": pageTitle,
|
|
132
|
+
description,
|
|
133
|
+
keywords: `${title},${config["publisher-name"]}`,
|
|
134
|
+
canonicalUrl: staticPageUrl,
|
|
135
|
+
ogUrl: staticPageUrl,
|
|
136
|
+
ogTitle,
|
|
137
|
+
ogDescription,
|
|
138
|
+
keywords: customSeo.keywords || keywords,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
115
142
|
// The findRelevantConfig method call has no ownerId for home page.
|
|
116
143
|
// This causes the seoMetadata to be undefined.
|
|
117
144
|
// So the default value for the ownerId is set to null.
|
|
@@ -188,6 +215,11 @@ function getSeoData(config, pageType, data, url = {}, seoConfig = {}) {
|
|
|
188
215
|
buildTagsFromAuthor(config, get(data, ["data", "author"], {}), url, data) ||
|
|
189
216
|
getSeoData(config, "home-page", data, url)
|
|
190
217
|
);
|
|
218
|
+
case "static-page":
|
|
219
|
+
return (
|
|
220
|
+
buildTagsFromStaticPage(config, lodash.get(data, ["data", "page"], {}), url, data) ||
|
|
221
|
+
getSeoData(config, "home-page", data, url)
|
|
222
|
+
);
|
|
191
223
|
case "shell":
|
|
192
224
|
return getShellSeoData(config);
|
|
193
225
|
default:
|