@quintype/seo 1.40.13 → 1.40.14-gsc-errors.1
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/index.js +34 -16
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
import { flatMap, get, omit, uniqBy } from "lodash";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import ReactDomServer from "react-dom/server";
|
|
4
|
-
import { StoryAmpTags } from
|
|
5
|
-
import { AuthorTags } from
|
|
6
|
-
import { generateStaticData, generateStructuredData } from
|
|
7
|
-
import { ImageTags } from
|
|
8
|
-
import { StaticTags } from
|
|
9
|
-
import { StructuredDataTags } from
|
|
10
|
-
import { getTitle, TextTags } from
|
|
4
|
+
import { StoryAmpTags } from "./src/amp-tags.js";
|
|
5
|
+
import { AuthorTags } from "./src/author-tags.js";
|
|
6
|
+
import { generateStaticData, generateStructuredData } from "./src/generate-common-seo";
|
|
7
|
+
import { ImageTags } from "./src/image-tags.js";
|
|
8
|
+
import { StaticTags } from "./src/static-tags.js";
|
|
9
|
+
import { StructuredDataTags } from "./src/structured-data/structured-data-tags.js";
|
|
10
|
+
import { getTitle, TextTags } from "./src/text-tags.js";
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
export {
|
|
13
|
+
TextTags,
|
|
14
|
+
StaticTags,
|
|
15
|
+
AuthorTags,
|
|
16
|
+
ImageTags,
|
|
17
|
+
StructuredDataTags,
|
|
18
|
+
StoryAmpTags,
|
|
19
|
+
generateStaticData,
|
|
20
|
+
generateStructuredData,
|
|
21
|
+
};
|
|
14
22
|
|
|
15
23
|
function tagToKey(tag) {
|
|
16
24
|
switch (tag.tag || "meta") {
|
|
17
|
-
case "meta":
|
|
18
|
-
|
|
19
|
-
case "
|
|
20
|
-
|
|
25
|
+
case "meta":
|
|
26
|
+
return `meta-${tag.name || tag.itemprop || "name"}-${tag.property || "property"}`;
|
|
27
|
+
case "link":
|
|
28
|
+
return `link-${tag.rel}`;
|
|
29
|
+
case "title":
|
|
30
|
+
return `title`;
|
|
31
|
+
default:
|
|
32
|
+
return Math.random().toString();
|
|
21
33
|
}
|
|
22
34
|
}
|
|
23
35
|
|
|
@@ -28,7 +40,9 @@ export class MetaTagList {
|
|
|
28
40
|
|
|
29
41
|
toString() {
|
|
30
42
|
const uniqueTags = uniqBy(this.tags.reverse(), tagToKey).reverse();
|
|
31
|
-
return ReactDomServer.renderToStaticMarkup(
|
|
43
|
+
return ReactDomServer.renderToStaticMarkup(
|
|
44
|
+
uniqueTags.map((tag) => React.createElement(tag.tag || "meta", omit(tag, "tag")))
|
|
45
|
+
);
|
|
32
46
|
}
|
|
33
47
|
|
|
34
48
|
addTag() {
|
|
@@ -93,12 +107,16 @@ export class SEO {
|
|
|
93
107
|
*/
|
|
94
108
|
constructor(seoConfig = {}) {
|
|
95
109
|
this.seoConfig = seoConfig;
|
|
96
|
-
this.generators = (
|
|
110
|
+
this.generators = (
|
|
111
|
+
seoConfig.generators || [TextTags, ImageTags, AuthorTags, StaticTags, StructuredDataTags, StoryAmpTags]
|
|
112
|
+
).concat(seoConfig.extraGenerators || []);
|
|
97
113
|
}
|
|
98
114
|
|
|
99
115
|
getMetaTags(config, pageType, data, params = {}) {
|
|
100
116
|
pageType = get(this.seoConfig, ["pageTypeAliases", pageType], pageType);
|
|
101
|
-
return new MetaTagList(
|
|
117
|
+
return new MetaTagList(
|
|
118
|
+
flatMap(this.generators, (generator) => generator(this.seoConfig, config, pageType, data, params))
|
|
119
|
+
);
|
|
102
120
|
}
|
|
103
121
|
|
|
104
122
|
getTitle(config, pageType, data, params = {}) {
|