@quintype/seo 1.40.14-gsc-errors.1 → 1.40.14-gsc-errors.3
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 +9 -10
- package/package.json +1 -1
- package/src/amp-tags.js +27 -21
package/dist/index.cjs.js
CHANGED
|
@@ -50,11 +50,11 @@ function isStoryPublic(story) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
function showAmpTag({ ampStoryPages = true }, pageType, story) {
|
|
53
|
-
if (!ampStoryPages || pageType !==
|
|
53
|
+
if (!ampStoryPages || pageType !== "story-page") {
|
|
54
54
|
return false;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
if (ampStoryPages ===
|
|
57
|
+
if (ampStoryPages === "public" && !isStoryPublic(story)) {
|
|
58
58
|
return false;
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -62,7 +62,7 @@ function showAmpTag({ ampStoryPages = true }, pageType, story) {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
const getDomain = (url, domainSlug) => {
|
|
65
|
-
const domain = domainSlug ? new URL(url).origin :
|
|
65
|
+
const domain = domainSlug ? new URL(url).origin : "";
|
|
66
66
|
try {
|
|
67
67
|
return domain;
|
|
68
68
|
} catch (err) {
|
|
@@ -81,18 +81,17 @@ const getDomain = (url, domainSlug) => {
|
|
|
81
81
|
* @param {...*} params See {@link Generator} for other Parameters
|
|
82
82
|
*/
|
|
83
83
|
function StoryAmpTags(seoConfig, config, pageType, data = {}, opts) {
|
|
84
|
-
|
|
85
84
|
const story = get__default["default"](data, ["data", "story"], {});
|
|
86
|
-
const { currentHostUrl =
|
|
85
|
+
const { currentHostUrl = "", domainSlug } = data;
|
|
87
86
|
// TODO: Remove this condition and always make absolute URL if that's better for AMP discoverability.
|
|
88
|
-
const ampUrlAppend = seoConfig.appendHostToAmpUrl ? getDomain(currentHostUrl, domainSlug) || config[
|
|
87
|
+
const ampUrlAppend = seoConfig.appendHostToAmpUrl ? getDomain(currentHostUrl, domainSlug) || config["sketches-host"] : "";
|
|
89
88
|
const storySlug = seoConfig.decodeAmpUrl ? decodeURIComponent(story.slug) : encodeURIComponent(story.slug);
|
|
90
89
|
const ampUrl = story["story-template"] === "visual-story" ? `${ampUrlAppend}/${storySlug}` : `${ampUrlAppend}/amp/story/${storySlug}`;
|
|
91
|
-
|
|
92
|
-
if (showAmpTag(seoConfig, pageType, story)) {
|
|
90
|
+
const ignoreStoryTemplate = seoConfig.ignoreAmpHtmlStoryTemplates && seoConfig.ignoreAmpHtmlStoryTemplates.includes(story["story-template"]);
|
|
91
|
+
if (showAmpTag(seoConfig, pageType, story) && !ignoreStoryTemplate) {
|
|
93
92
|
return [{
|
|
94
|
-
tag:
|
|
95
|
-
rel:
|
|
93
|
+
tag: "link",
|
|
94
|
+
rel: "amphtml",
|
|
96
95
|
href: ampUrl
|
|
97
96
|
}];
|
|
98
97
|
} else {
|
package/package.json
CHANGED
package/src/amp-tags.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import get from
|
|
2
|
-
import { isStoryPublic } from
|
|
1
|
+
import get from "lodash/get";
|
|
2
|
+
import { isStoryPublic } from "./utils";
|
|
3
3
|
|
|
4
4
|
function showAmpTag({ ampStoryPages = true }, pageType, story) {
|
|
5
|
-
if (!ampStoryPages || pageType !==
|
|
5
|
+
if (!ampStoryPages || pageType !== "story-page") {
|
|
6
6
|
return false;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
if (ampStoryPages ===
|
|
9
|
+
if (ampStoryPages === "public" && !isStoryPublic(story)) {
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -14,14 +14,13 @@ function showAmpTag({ ampStoryPages = true }, pageType, story) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
const getDomain = (url, domainSlug) => {
|
|
17
|
-
const domain = domainSlug ? new URL(url).origin :
|
|
17
|
+
const domain = domainSlug ? new URL(url).origin : "";
|
|
18
18
|
try {
|
|
19
19
|
return domain;
|
|
20
|
+
} catch (err) {
|
|
21
|
+
return "";
|
|
20
22
|
}
|
|
21
|
-
|
|
22
|
-
return ""
|
|
23
|
-
}
|
|
24
|
-
}
|
|
23
|
+
};
|
|
25
24
|
|
|
26
25
|
/**
|
|
27
26
|
* StoryAmpTags adds the amphref to stories which support amp.
|
|
@@ -34,20 +33,27 @@ const getDomain = (url, domainSlug) => {
|
|
|
34
33
|
* @param {...*} params See {@link Generator} for other Parameters
|
|
35
34
|
*/
|
|
36
35
|
export function StoryAmpTags(seoConfig, config, pageType, data = {}, opts) {
|
|
37
|
-
|
|
38
36
|
const story = get(data, ["data", "story"], {});
|
|
39
|
-
const { currentHostUrl =
|
|
37
|
+
const { currentHostUrl = "", domainSlug } = data;
|
|
40
38
|
// TODO: Remove this condition and always make absolute URL if that's better for AMP discoverability.
|
|
41
|
-
const ampUrlAppend = seoConfig.appendHostToAmpUrl
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
const ampUrlAppend = seoConfig.appendHostToAmpUrl
|
|
40
|
+
? getDomain(currentHostUrl, domainSlug) || config["sketches-host"]
|
|
41
|
+
: "";
|
|
42
|
+
const storySlug = seoConfig.decodeAmpUrl ? decodeURIComponent(story.slug) : encodeURIComponent(story.slug);
|
|
43
|
+
const ampUrl =
|
|
44
|
+
story["story-template"] === "visual-story"
|
|
45
|
+
? `${ampUrlAppend}/${storySlug}`
|
|
46
|
+
: `${ampUrlAppend}/amp/story/${storySlug}`;
|
|
47
|
+
const ignoreStoryTemplate =
|
|
48
|
+
seoConfig.ignoreAmpHtmlStoryTemplates && seoConfig.ignoreAmpHtmlStoryTemplates.includes(story["story-template"]);
|
|
49
|
+
if (showAmpTag(seoConfig, pageType, story) && !ignoreStoryTemplate) {
|
|
50
|
+
return [
|
|
51
|
+
{
|
|
52
|
+
tag: "link",
|
|
53
|
+
rel: "amphtml",
|
|
54
|
+
href: ampUrl,
|
|
55
|
+
},
|
|
56
|
+
];
|
|
51
57
|
} else {
|
|
52
58
|
return [];
|
|
53
59
|
}
|