@quintype/seo 1.41.3 → 1.41.4-gsc-errors-fix.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/dist/index.cjs.js +3 -1
- package/package.json +1 -1
- package/src/amp-tags.js +3 -2
- package/test/amp_tags_test.js +2 -8
package/dist/index.cjs.js
CHANGED
|
@@ -78,16 +78,18 @@ const getDomain = (url, domainSlug) => {
|
|
|
78
78
|
* @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
|
|
79
79
|
* @param {(boolean)} seoConfig.appendHostToAmpUrl If set to true, the url to be appended to the slug is computed based on the currentHostUrl and the domain slug, else the url is taken as the sketches host. Default: false
|
|
80
80
|
* @param {(boolean)} seoConfig.decodeAmpUrl If set to true, the storySlug that goes as the amp href url is decoded, else the storyslug is encoded. Default: false
|
|
81
|
+
* @param {(boolean)} seoConfig.ignoreAmpHtmlStoryTemplates pass all the story templates you want to ignore from add rel="amphtml" tag. Default: ["visual story"]
|
|
81
82
|
* @param {...*} params See {@link Generator} for other Parameters
|
|
82
83
|
*/
|
|
83
84
|
function StoryAmpTags(seoConfig, config, pageType, data = {}, opts) {
|
|
85
|
+
const templatesToIgnore = seoConfig.ignoreAmpHtmlStoryTemplates || ["visual-story"];
|
|
84
86
|
const story = get__default["default"](data, ["data", "story"], {});
|
|
85
87
|
const { currentHostUrl = "", domainSlug } = data;
|
|
86
88
|
// TODO: Remove this condition and always make absolute URL if that's better for AMP discoverability.
|
|
87
89
|
const ampUrlAppend = seoConfig.appendHostToAmpUrl ? getDomain(currentHostUrl, domainSlug) || config["sketches-host"] : "";
|
|
88
90
|
const storySlug = seoConfig.decodeAmpUrl ? decodeURIComponent(story.slug) : encodeURIComponent(story.slug);
|
|
89
91
|
const ampUrl = story["story-template"] === "visual-story" ? `${ampUrlAppend}/${storySlug}` : `${ampUrlAppend}/amp/story/${storySlug}`;
|
|
90
|
-
const ignoreStoryTemplate =
|
|
92
|
+
const ignoreStoryTemplate = templatesToIgnore.includes(story["story-template"]);
|
|
91
93
|
if (showAmpTag(seoConfig, pageType, story) && !ignoreStoryTemplate) {
|
|
92
94
|
return [{
|
|
93
95
|
tag: "link",
|
package/package.json
CHANGED
package/src/amp-tags.js
CHANGED
|
@@ -30,9 +30,11 @@ const getDomain = (url, domainSlug) => {
|
|
|
30
30
|
* @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
|
|
31
31
|
* @param {(boolean)} seoConfig.appendHostToAmpUrl If set to true, the url to be appended to the slug is computed based on the currentHostUrl and the domain slug, else the url is taken as the sketches host. Default: false
|
|
32
32
|
* @param {(boolean)} seoConfig.decodeAmpUrl If set to true, the storySlug that goes as the amp href url is decoded, else the storyslug is encoded. Default: false
|
|
33
|
+
* @param {(boolean)} seoConfig.ignoreAmpHtmlStoryTemplates pass all the story templates you want to ignore from add rel="amphtml" tag. Default: ["visual story"]
|
|
33
34
|
* @param {...*} params See {@link Generator} for other Parameters
|
|
34
35
|
*/
|
|
35
36
|
export function StoryAmpTags(seoConfig, config, pageType, data = {}, opts) {
|
|
37
|
+
const templatesToIgnore = seoConfig.ignoreAmpHtmlStoryTemplates || ["visual-story"];
|
|
36
38
|
const story = get(data, ["data", "story"], {});
|
|
37
39
|
const { currentHostUrl = "", domainSlug } = data;
|
|
38
40
|
// TODO: Remove this condition and always make absolute URL if that's better for AMP discoverability.
|
|
@@ -44,8 +46,7 @@ export function StoryAmpTags(seoConfig, config, pageType, data = {}, opts) {
|
|
|
44
46
|
story["story-template"] === "visual-story"
|
|
45
47
|
? `${ampUrlAppend}/${storySlug}`
|
|
46
48
|
: `${ampUrlAppend}/amp/story/${storySlug}`;
|
|
47
|
-
const ignoreStoryTemplate =
|
|
48
|
-
seoConfig.ignoreAmpHtmlStoryTemplates && seoConfig.ignoreAmpHtmlStoryTemplates.includes(story["story-template"]);
|
|
49
|
+
const ignoreStoryTemplate = templatesToIgnore.includes(story["story-template"]);
|
|
49
50
|
if (showAmpTag(seoConfig, pageType, story) && !ignoreStoryTemplate) {
|
|
50
51
|
return [
|
|
51
52
|
{
|
package/test/amp_tags_test.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const { StoryAmpTags } = require("..");
|
|
2
2
|
const { getSeoMetadata, assertContains } = require("./utils");
|
|
3
3
|
|
|
4
|
-
const assert = require(
|
|
4
|
+
const assert = require("assert");
|
|
5
5
|
|
|
6
|
-
describe(
|
|
6
|
+
describe("AmpTags", function () {
|
|
7
7
|
const seoConfig = {
|
|
8
8
|
generators: [StoryAmpTags],
|
|
9
9
|
ampStoryPages: true,
|
|
@@ -19,12 +19,6 @@ 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
|
-
|
|
28
22
|
it("does not rely on is-amp-supported in story API", function () {
|
|
29
23
|
const story = { slug: "section/slug", "is-amp-supported": false };
|
|
30
24
|
const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, {});
|