@quintype/seo 1.40.3 → 1.40.5-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 +2 -0
- package/dist/index.cjs.js +1 -5
- package/package.json +1 -1
- package/src/amp-tags.js +1 -5
- package/test/amp_tags_test.js +54 -31
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
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.4](https://github.com/quintype/quintype-node-seo/compare/v1.40.4-amptag.0...v1.40.4) (2022-03-22)
|
|
6
|
+
|
|
5
7
|
### [1.40.3](https://github.com/quintype/quintype-node-seo/compare/v1.40.2...v1.40.3) (2022-02-23)
|
|
6
8
|
|
|
7
9
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -1026,10 +1026,6 @@ function showAmpTag({ ampStoryPages = true }, pageType, story) {
|
|
|
1026
1026
|
return false;
|
|
1027
1027
|
}
|
|
1028
1028
|
|
|
1029
|
-
if (!get__default["default"](story, ["is-amp-supported"])) {
|
|
1030
|
-
return false;
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
1029
|
if (ampStoryPages === 'public' && !isStoryPublic(story)) {
|
|
1034
1030
|
return false;
|
|
1035
1031
|
}
|
|
@@ -1067,7 +1063,7 @@ function StoryAmpTags(seoConfig, config, pageType, data = {}, opts) {
|
|
|
1067
1063
|
return [{
|
|
1068
1064
|
tag: 'link',
|
|
1069
1065
|
rel: 'amphtml',
|
|
1070
|
-
href: `${ampUrlAppend}/amp/story/${storySlug}`
|
|
1066
|
+
href: `${ampUrlAppend}/amp/story/${storySlug.replace("ampstories/", "")}`
|
|
1071
1067
|
}];
|
|
1072
1068
|
} else {
|
|
1073
1069
|
return [];
|
package/package.json
CHANGED
package/src/amp-tags.js
CHANGED
|
@@ -6,10 +6,6 @@ function showAmpTag({ ampStoryPages = true }, pageType, story) {
|
|
|
6
6
|
return false;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
if (!get(story, ["is-amp-supported"])) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
9
|
if (ampStoryPages === 'public' && !isStoryPublic(story)) {
|
|
14
10
|
return false;
|
|
15
11
|
}
|
|
@@ -48,7 +44,7 @@ export function StoryAmpTags(seoConfig, config, pageType, data = {}, opts) {
|
|
|
48
44
|
return [{
|
|
49
45
|
tag: 'link',
|
|
50
46
|
rel: 'amphtml',
|
|
51
|
-
href: `${ampUrlAppend}/amp/story/${storySlug}`
|
|
47
|
+
href: `${ampUrlAppend}/amp/story/${storySlug.replace("ampstories/", "")}`
|
|
52
48
|
}];
|
|
53
49
|
} else {
|
|
54
50
|
return [];
|
package/test/amp_tags_test.js
CHANGED
|
@@ -6,60 +6,83 @@ const assert = require('assert');
|
|
|
6
6
|
describe('AmpTags', function () {
|
|
7
7
|
const seoConfig = {
|
|
8
8
|
generators: [StoryAmpTags],
|
|
9
|
-
ampStoryPages: true
|
|
10
|
-
}
|
|
9
|
+
ampStoryPages: true,
|
|
10
|
+
};
|
|
11
11
|
|
|
12
12
|
const config = {
|
|
13
|
-
|
|
14
|
-
}
|
|
13
|
+
"sketches-host": "https://madrid.quintype.io",
|
|
14
|
+
};
|
|
15
15
|
|
|
16
|
-
it("gets amp tags for supported stories", function() {
|
|
17
|
-
const story = {
|
|
18
|
-
const string = getSeoMetadata(seoConfig, config,
|
|
16
|
+
it("gets amp tags for supported stories", function () {
|
|
17
|
+
const story = { slug: "section/slug", "is-amp-supported": true };
|
|
18
|
+
const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, {});
|
|
19
19
|
assertContains('<link rel="amphtml" href="/amp/story/section%2Fslug"/>', string);
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
it("does not
|
|
23
|
-
const story = {
|
|
24
|
-
const string = getSeoMetadata(seoConfig, config,
|
|
25
|
-
|
|
22
|
+
it("does not rely on is-amp-supported in story API", function () {
|
|
23
|
+
const story = { slug: "section/slug", "is-amp-supported": false };
|
|
24
|
+
const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, {});
|
|
25
|
+
assertContains('<link rel="amphtml" href="/amp/story/section%2Fslug"/>', string);
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
it("does not add amphtml link tag to amp story pages", function () {
|
|
29
|
-
const story = {
|
|
30
|
-
const string = getSeoMetadata(seoConfig, config,
|
|
31
|
-
assert.equal(
|
|
29
|
+
const story = { slug: "section/slug", "is-amp-supported": true };
|
|
30
|
+
const string = getSeoMetadata(seoConfig, config, "story-page-amp", { data: { story: story } }, {});
|
|
31
|
+
assert.equal("", string);
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
it("does not ampify other pages", function () {
|
|
35
|
-
const string = getSeoMetadata(seoConfig, config,
|
|
36
|
-
assert.equal(
|
|
35
|
+
const string = getSeoMetadata(seoConfig, config, "home-page", { data: {} }, {});
|
|
36
|
+
assert.equal("", string);
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
it("does allows you to only ampify free story pages", function () {
|
|
40
|
-
const story = {
|
|
41
|
-
const publicStoryResults = getSeoMetadata(
|
|
40
|
+
const story = { slug: "section/slug", "is-amp-supported": true };
|
|
41
|
+
const publicStoryResults = getSeoMetadata(
|
|
42
|
+
{ ...seoConfig, ampStoryPages: "public" },
|
|
43
|
+
config,
|
|
44
|
+
"story-page",
|
|
45
|
+
{ data: { story: story } },
|
|
46
|
+
{}
|
|
47
|
+
);
|
|
42
48
|
assert.equal('<link rel="amphtml" href="/amp/story/section%2Fslug"/>', publicStoryResults);
|
|
43
|
-
const privateStoryResults = getSeoMetadata(
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
const privateStoryResults = getSeoMetadata(
|
|
50
|
+
{ ...seoConfig, ampStoryPages: "public" },
|
|
51
|
+
config,
|
|
52
|
+
"story-page",
|
|
53
|
+
{ data: { story: { ...story, access: "subscription" } } },
|
|
54
|
+
{}
|
|
55
|
+
);
|
|
56
|
+
assert.equal("", privateStoryResults);
|
|
57
|
+
});
|
|
46
58
|
|
|
47
59
|
it("does not append domain to amp stories if appendHostToAmpUrl not present", function () {
|
|
48
|
-
const story = {
|
|
49
|
-
const string = getSeoMetadata(seoConfig, config,
|
|
60
|
+
const story = { slug: "section/slug", "is-amp-supported": true };
|
|
61
|
+
const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, {});
|
|
50
62
|
assertContains('<link rel="amphtml" href="/amp/story/section%2Fslug"/>', string);
|
|
51
|
-
})
|
|
63
|
+
});
|
|
52
64
|
|
|
53
65
|
it("does append domain to amp stories if appendHostToAmpUrl present", function () {
|
|
54
|
-
const story = {
|
|
55
|
-
const string = getSeoMetadata(
|
|
66
|
+
const story = { slug: "section/slug", "is-amp-supported": true };
|
|
67
|
+
const string = getSeoMetadata(
|
|
68
|
+
{ ...seoConfig, appendHostToAmpUrl: true },
|
|
69
|
+
config,
|
|
70
|
+
"story-page",
|
|
71
|
+
{ currentHostUrl: "https://madrid.quintype.io/section/slug", data: { story } },
|
|
72
|
+
{}
|
|
73
|
+
);
|
|
56
74
|
assertContains('<link rel="amphtml" href="https://madrid.quintype.io/amp/story/section%2Fslug"/>', string);
|
|
57
|
-
})
|
|
75
|
+
});
|
|
58
76
|
|
|
59
77
|
it("does encode the url if encodeAmpUrl is set to false in seoConfig", function () {
|
|
60
|
-
const story = {
|
|
61
|
-
const string = getSeoMetadata(
|
|
78
|
+
const story = { slug: "section%2Fslug", "is-amp-supported": true };
|
|
79
|
+
const string = getSeoMetadata(
|
|
80
|
+
{ ...seoConfig, appendHostToAmpUrl: true, decodeAmpUrl: true },
|
|
81
|
+
config,
|
|
82
|
+
"story-page",
|
|
83
|
+
{ currentHostUrl: "https://madrid.quintype.io/section%2Fslug", data: { story } },
|
|
84
|
+
{}
|
|
85
|
+
);
|
|
62
86
|
assertContains('<link rel="amphtml" href="https://madrid.quintype.io/amp/story/section/slug"/>', string);
|
|
63
|
-
})
|
|
64
|
-
|
|
87
|
+
});
|
|
65
88
|
});
|