@quintype/seo 1.43.0 → 1.44.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 +10 -1
- package/dist/index.cjs.js +10 -2
- package/package.json +1 -1
- package/src/amp-tags.js +10 -2
- package/test/amp_tags_test.js +20 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,16 @@
|
|
|
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.
|
|
5
|
+
## [1.44.0](https://github.com/quintype/quintype-node-seo/compare/v1.43.0...v1.44.0) (2024-01-04)
|
|
6
|
+
|
|
7
|
+
## [1.43.0-disable-amp-story.1](https://github.com/quintype/quintype-node-seo/compare/v1.43.0-disable-amp-story.0...v1.43.0-disable-amp-story.1) (2023-11-22)
|
|
8
|
+
|
|
9
|
+
## [1.43.0-disable-amp-story.0](https://github.com/quintype/quintype-node-seo/compare/v1.42.2...v1.43.0-disable-amp-story.0) (2023-11-22)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* disable amp for a particular story ([6b5a76d](https://github.com/quintype/quintype-node-seo/commit/6b5a76da754bf2cbabd9a8d0787095366bf18609))
|
|
6
15
|
|
|
7
16
|
### [1.42.2](https://github.com/quintype/quintype-node-seo/compare/v1.42.1...v1.42.2) (2023-07-06)
|
|
8
17
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -62,6 +62,12 @@ function showAmpTag({ ampStoryPages = true }, pageType, story) {
|
|
|
62
62
|
return false;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
const isAmpDisabled = get__default["default"](story, ["metadata", "story-attributes", "disable-amp-for-single-story", "0"], "false");
|
|
66
|
+
|
|
67
|
+
if (isAmpDisabled === "true") {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
65
71
|
if (ampStoryPages === "public" && !isStoryPublic(story)) {
|
|
66
72
|
return false;
|
|
67
73
|
}
|
|
@@ -81,6 +87,9 @@ const getDomain = (url, domainSlug) => {
|
|
|
81
87
|
/**
|
|
82
88
|
* StoryAmpTags adds the amphref to stories which support amp.
|
|
83
89
|
*
|
|
90
|
+
* To disable adding amphref for a specific story, you need to create a story attribute in bold with the slug {disable-amp-for-single-story} and values {true} and {false}. Set its value to "true" in the story which you want to disable amp. Please make sure to name the attributes and values in the exact same way as mentioned
|
|
91
|
+
* attribute slug: "disable-amp-for-single-story" values: "true" , "false"
|
|
92
|
+
*
|
|
84
93
|
* @extends Generator
|
|
85
94
|
* @param {*} seoConfig
|
|
86
95
|
* @param {(boolean|"public")} seoConfig.ampStoryPages Should amp story pages be shown for all stories (true), not shown (false), or only be shown for public stories ("public"). Default: true
|
|
@@ -96,8 +105,7 @@ function StoryAmpTags(seoConfig, config, pageType, data = {}, opts) {
|
|
|
96
105
|
// TODO: Remove this condition and always make absolute URL if that's better for AMP discoverability.
|
|
97
106
|
const ampUrlAppend = seoConfig.appendHostToAmpUrl ? getDomain(currentHostUrl, domainSlug) || config["sketches-host"] : "";
|
|
98
107
|
const storySlug = seoConfig.decodeAmpUrl ? decodeURIComponent(story.slug) : encodeURIComponent(story.slug);
|
|
99
|
-
const
|
|
100
|
-
const ampUrl = story["story-template"] === "visual-story" ? `${ampUrlAppend}/${storySlug}` : `${ampUrlAppend}${ampPageBasePath}/${storySlug}`;
|
|
108
|
+
const ampUrl = story["story-template"] === "visual-story" ? `${ampUrlAppend}/${storySlug}` : `${ampUrlAppend}/amp/story/${storySlug}`;
|
|
101
109
|
const ignoreStoryTemplate = templatesToIgnore.includes(story["story-template"]);
|
|
102
110
|
if (showAmpTag(seoConfig, pageType, story) && !ignoreStoryTemplate) {
|
|
103
111
|
return [{
|
package/package.json
CHANGED
package/src/amp-tags.js
CHANGED
|
@@ -6,6 +6,12 @@ function showAmpTag({ ampStoryPages = true }, pageType, story) {
|
|
|
6
6
|
return false;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
const isAmpDisabled = get(story, ["metadata", "story-attributes", "disable-amp-for-single-story", "0"], "false");
|
|
10
|
+
|
|
11
|
+
if (isAmpDisabled === "true") {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
if (ampStoryPages === "public" && !isStoryPublic(story)) {
|
|
10
16
|
return false;
|
|
11
17
|
}
|
|
@@ -25,6 +31,9 @@ const getDomain = (url, domainSlug) => {
|
|
|
25
31
|
/**
|
|
26
32
|
* StoryAmpTags adds the amphref to stories which support amp.
|
|
27
33
|
*
|
|
34
|
+
* To disable adding amphref for a specific story, you need to create a story attribute in bold with the slug {disable-amp-for-single-story} and values {true} and {false}. Set its value to "true" in the story which you want to disable amp. Please make sure to name the attributes and values in the exact same way as mentioned
|
|
35
|
+
* attribute slug: "disable-amp-for-single-story" values: "true" , "false"
|
|
36
|
+
*
|
|
28
37
|
* @extends Generator
|
|
29
38
|
* @param {*} seoConfig
|
|
30
39
|
* @param {(boolean|"public")} seoConfig.ampStoryPages Should amp story pages be shown for all stories (true), not shown (false), or only be shown for public stories ("public"). Default: true
|
|
@@ -42,11 +51,10 @@ export function StoryAmpTags(seoConfig, config, pageType, data = {}, opts) {
|
|
|
42
51
|
? getDomain(currentHostUrl, domainSlug) || config["sketches-host"]
|
|
43
52
|
: "";
|
|
44
53
|
const storySlug = seoConfig.decodeAmpUrl ? decodeURIComponent(story.slug) : encodeURIComponent(story.slug);
|
|
45
|
-
const { ampPageBasePath = "/amp/story" } = seoConfig;
|
|
46
54
|
const ampUrl =
|
|
47
55
|
story["story-template"] === "visual-story"
|
|
48
56
|
? `${ampUrlAppend}/${storySlug}`
|
|
49
|
-
: `${ampUrlAppend}
|
|
57
|
+
: `${ampUrlAppend}/amp/story/${storySlug}`;
|
|
50
58
|
const ignoreStoryTemplate = templatesToIgnore.includes(story["story-template"]);
|
|
51
59
|
if (showAmpTag(seoConfig, pageType, story) && !ignoreStoryTemplate) {
|
|
52
60
|
return [
|
package/test/amp_tags_test.js
CHANGED
|
@@ -25,6 +25,26 @@ describe("AmpTags", function () {
|
|
|
25
25
|
assertContains('<link rel="amphtml" href="/amp/story/section%2Fslug"/>', string);
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
+
it("does not add amphtml link tag to story pages which has disableamp attribute set to true", function () {
|
|
29
|
+
const story = {
|
|
30
|
+
slug: "section/slug",
|
|
31
|
+
"is-amp-supported": true,
|
|
32
|
+
metadata: { "story-attributes": { "disable-amp-for-single-story": ["true"] } },
|
|
33
|
+
};
|
|
34
|
+
const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, {});
|
|
35
|
+
assert.equal("", string);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("does not add amphtml link tag to story pages which has disableamp attribute set to false", function () {
|
|
39
|
+
const story = {
|
|
40
|
+
slug: "section/slug",
|
|
41
|
+
"is-amp-supported": true,
|
|
42
|
+
metadata: { "story-attributes": { "disable-amp-for-single-story": ["false"] } },
|
|
43
|
+
};
|
|
44
|
+
const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, {});
|
|
45
|
+
assert.equal('<link rel="amphtml" href="/amp/story/section%2Fslug"/>', string);
|
|
46
|
+
});
|
|
47
|
+
|
|
28
48
|
it("does not add amphtml link tag to amp story pages", function () {
|
|
29
49
|
const story = { slug: "section/slug", "is-amp-supported": true };
|
|
30
50
|
const string = getSeoMetadata(seoConfig, config, "story-page-amp", { data: { story: story } }, {});
|