@quintype/seo 1.40.6 → 1.40.8-embed-url.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 -1
- package/CHANGELOG.md +7 -0
- package/dist/index.cjs.js +25 -2
- package/package.json +1 -1
- package/src/amp-tags.js +3 -1
- package/src/structured-data/structured-data-tags.js +24 -6
- package/test/amp_tags_test.js +6 -0
package/.vscode/settings.json
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
4
4
|
},
|
|
5
5
|
"editor.tabSize": 2,
|
|
6
|
-
"editor.formatOnSave": true,
|
|
7
6
|
"editor.detectIndentation": false,
|
|
7
|
+
"editor.formatOnSave": true,
|
|
8
8
|
"files.insertFinalNewline": true,
|
|
9
9
|
"files.trimTrailingWhitespace": true,
|
|
10
10
|
"editor.codeActionsOnSave": {
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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.7](https://github.com/quintype/quintype-node-seo/compare/v1.40.6...v1.40.7) (2022-07-11)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* Amphtml error ([#526](https://github.com/quintype/quintype-node-seo/issues/526)) ([24b6c61](https://github.com/quintype/quintype-node-seo/commit/24b6c616118f3db1a2cdda0d98d2827bf2a0d099))
|
|
11
|
+
|
|
5
12
|
### [1.40.6](https://github.com/quintype/quintype-node-seo/compare/v1.40.5...v1.40.6) (2022-07-11)
|
|
6
13
|
|
|
7
14
|
### [1.40.5](https://github.com/quintype/quintype-node-seo/compare/v1.40.1...v1.40.5) (2022-06-30)
|
package/dist/index.cjs.js
CHANGED
|
@@ -822,9 +822,30 @@ function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherC
|
|
|
822
822
|
};
|
|
823
823
|
}
|
|
824
824
|
|
|
825
|
+
function getEmbedUrl(cards) {
|
|
826
|
+
let embedUrl = "";
|
|
827
|
+
|
|
828
|
+
// not using the return value of top level find
|
|
829
|
+
// coz we only need the embed url
|
|
830
|
+
// find is used for early exit
|
|
831
|
+
cards.find(card => {
|
|
832
|
+
const storyElements = card["story-elements"];
|
|
833
|
+
return storyElements.find((elem, index) => {
|
|
834
|
+
if (elem["embed-url"]) {
|
|
835
|
+
embedUrl = elem["embed-url"];
|
|
836
|
+
return true;
|
|
837
|
+
}
|
|
838
|
+
return false;
|
|
839
|
+
});
|
|
840
|
+
});
|
|
841
|
+
|
|
842
|
+
return embedUrl;
|
|
843
|
+
}
|
|
844
|
+
|
|
825
845
|
function generateVideoArticleData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
|
|
826
846
|
const metaKeywords = story.seo && story.seo["meta-keywords"] || [];
|
|
827
|
-
const
|
|
847
|
+
const storyCards = get__default["default"](story, ["cards"], []);
|
|
848
|
+
const embedUrl = getEmbedUrl(storyCards);
|
|
828
849
|
const socialShareMsg = get__default["default"](story, ["summary"], "");
|
|
829
850
|
const metaDescription = get__default["default"](story, ["seo", "meta-description"], "");
|
|
830
851
|
const subHeadline = get__default["default"](story, ["subheadline"], "");
|
|
@@ -1090,11 +1111,13 @@ function StoryAmpTags(seoConfig, config, pageType, data = {}, opts) {
|
|
|
1090
1111
|
// TODO: Remove this condition and always make absolute URL if that's better for AMP discoverability.
|
|
1091
1112
|
const ampUrlAppend = seoConfig.appendHostToAmpUrl ? getDomain(currentHostUrl, domainSlug) || config['sketches-host'] : '';
|
|
1092
1113
|
const storySlug = seoConfig.decodeAmpUrl ? decodeURIComponent(story.slug) : encodeURIComponent(story.slug);
|
|
1114
|
+
const ampUrl = story["story-template"] === "visual-story" ? `${ampUrlAppend}/${storySlug}` : `${ampUrlAppend}/amp/story/${storySlug}`;
|
|
1115
|
+
|
|
1093
1116
|
if (showAmpTag(seoConfig, pageType, story)) {
|
|
1094
1117
|
return [{
|
|
1095
1118
|
tag: 'link',
|
|
1096
1119
|
rel: 'amphtml',
|
|
1097
|
-
href:
|
|
1120
|
+
href: ampUrl
|
|
1098
1121
|
}];
|
|
1099
1122
|
} else {
|
|
1100
1123
|
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 [];
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
getSchemaPerson,
|
|
12
12
|
getSchemaPublisher,
|
|
13
13
|
getSchemaType,
|
|
14
|
-
getSchemaWebsite
|
|
14
|
+
getSchemaWebsite,
|
|
15
15
|
} from "./schema";
|
|
16
16
|
|
|
17
17
|
function getLdJsonFields(type, fields) {
|
|
@@ -254,9 +254,30 @@ function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherC
|
|
|
254
254
|
};
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
+
function getEmbedUrl(cards) {
|
|
258
|
+
let embedUrl = "";
|
|
259
|
+
|
|
260
|
+
// not using the return value of top level find
|
|
261
|
+
// coz we only need the embed url
|
|
262
|
+
// find is used for early exit
|
|
263
|
+
cards.find((card) => {
|
|
264
|
+
const storyElements = card["story-elements"];
|
|
265
|
+
return storyElements.find((elem, index) => {
|
|
266
|
+
if (elem["embed-url"]) {
|
|
267
|
+
embedUrl = elem["embed-url"];
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
return false;
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
return embedUrl;
|
|
275
|
+
}
|
|
276
|
+
|
|
257
277
|
function generateVideoArticleData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
|
|
258
278
|
const metaKeywords = (story.seo && story.seo["meta-keywords"]) || [];
|
|
259
|
-
const
|
|
279
|
+
const storyCards = get(story, ["cards"], []);
|
|
280
|
+
const embedUrl = getEmbedUrl(storyCards);
|
|
260
281
|
const socialShareMsg = get(story, ["summary"], "");
|
|
261
282
|
const metaDescription = get(story, ["seo", "meta-description"], "");
|
|
262
283
|
const subHeadline = get(story, ["subheadline"], "");
|
|
@@ -476,10 +497,7 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re
|
|
|
476
497
|
}
|
|
477
498
|
|
|
478
499
|
if (structuredData.enableVideo && story["story-template"] === "video") {
|
|
479
|
-
return ldJson(
|
|
480
|
-
"VideoObject",
|
|
481
|
-
generateVideoArticleData(structuredData, story, publisherConfig, timezone)
|
|
482
|
-
);
|
|
500
|
+
return ldJson("VideoObject", generateVideoArticleData(structuredData, story, publisherConfig, timezone));
|
|
483
501
|
}
|
|
484
502
|
|
|
485
503
|
if (structuredData.enableNewsArticle !== "withoutArticleSchema") {
|
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 } }, {});
|