@masters-ws/react-seo 1.4.0 → 1.4.2
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/README.md +1 -0
- package/dist/chunk-UBBPNSEV.mjs +1016 -0
- package/dist/core/index.mjs +1 -1
- package/dist/index.js +989 -27
- package/dist/index.mjs +974 -23
- package/package.json +3 -9
package/dist/index.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
6
11
|
var __export = (target, all) => {
|
|
7
12
|
for (var name in all)
|
|
8
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -15,8 +20,167 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
20
|
}
|
|
16
21
|
return to;
|
|
17
22
|
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
18
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
32
|
|
|
33
|
+
// node_modules/react-fast-compare/index.js
|
|
34
|
+
var require_react_fast_compare = __commonJS({
|
|
35
|
+
"node_modules/react-fast-compare/index.js"(exports2, module2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
var hasElementType = typeof Element !== "undefined";
|
|
38
|
+
var hasMap = typeof Map === "function";
|
|
39
|
+
var hasSet = typeof Set === "function";
|
|
40
|
+
var hasArrayBuffer = typeof ArrayBuffer === "function" && !!ArrayBuffer.isView;
|
|
41
|
+
function equal(a, b) {
|
|
42
|
+
if (a === b) return true;
|
|
43
|
+
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
44
|
+
if (a.constructor !== b.constructor) return false;
|
|
45
|
+
var length, i, keys;
|
|
46
|
+
if (Array.isArray(a)) {
|
|
47
|
+
length = a.length;
|
|
48
|
+
if (length != b.length) return false;
|
|
49
|
+
for (i = length; i-- !== 0; )
|
|
50
|
+
if (!equal(a[i], b[i])) return false;
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
var it;
|
|
54
|
+
if (hasMap && a instanceof Map && b instanceof Map) {
|
|
55
|
+
if (a.size !== b.size) return false;
|
|
56
|
+
it = a.entries();
|
|
57
|
+
while (!(i = it.next()).done)
|
|
58
|
+
if (!b.has(i.value[0])) return false;
|
|
59
|
+
it = a.entries();
|
|
60
|
+
while (!(i = it.next()).done)
|
|
61
|
+
if (!equal(i.value[1], b.get(i.value[0]))) return false;
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
if (hasSet && a instanceof Set && b instanceof Set) {
|
|
65
|
+
if (a.size !== b.size) return false;
|
|
66
|
+
it = a.entries();
|
|
67
|
+
while (!(i = it.next()).done)
|
|
68
|
+
if (!b.has(i.value[0])) return false;
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
if (hasArrayBuffer && ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
|
|
72
|
+
length = a.length;
|
|
73
|
+
if (length != b.length) return false;
|
|
74
|
+
for (i = length; i-- !== 0; )
|
|
75
|
+
if (a[i] !== b[i]) return false;
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
|
79
|
+
if (a.valueOf !== Object.prototype.valueOf && typeof a.valueOf === "function" && typeof b.valueOf === "function") return a.valueOf() === b.valueOf();
|
|
80
|
+
if (a.toString !== Object.prototype.toString && typeof a.toString === "function" && typeof b.toString === "function") return a.toString() === b.toString();
|
|
81
|
+
keys = Object.keys(a);
|
|
82
|
+
length = keys.length;
|
|
83
|
+
if (length !== Object.keys(b).length) return false;
|
|
84
|
+
for (i = length; i-- !== 0; )
|
|
85
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
86
|
+
if (hasElementType && a instanceof Element) return false;
|
|
87
|
+
for (i = length; i-- !== 0; ) {
|
|
88
|
+
if ((keys[i] === "_owner" || keys[i] === "__v" || keys[i] === "__o") && a.$$typeof) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (!equal(a[keys[i]], b[keys[i]])) return false;
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
return a !== a && b !== b;
|
|
96
|
+
}
|
|
97
|
+
module2.exports = function isEqual(a, b) {
|
|
98
|
+
try {
|
|
99
|
+
return equal(a, b);
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if ((error.message || "").match(/stack|recursion/i)) {
|
|
102
|
+
console.warn("react-fast-compare cannot handle circular refs");
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// node_modules/invariant/invariant.js
|
|
112
|
+
var require_invariant = __commonJS({
|
|
113
|
+
"node_modules/invariant/invariant.js"(exports2, module2) {
|
|
114
|
+
"use strict";
|
|
115
|
+
var NODE_ENV = process.env.NODE_ENV;
|
|
116
|
+
var invariant2 = function(condition, format, a, b, c, d, e, f) {
|
|
117
|
+
if (NODE_ENV !== "production") {
|
|
118
|
+
if (format === void 0) {
|
|
119
|
+
throw new Error("invariant requires an error message argument");
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (!condition) {
|
|
123
|
+
var error;
|
|
124
|
+
if (format === void 0) {
|
|
125
|
+
error = new Error(
|
|
126
|
+
"Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings."
|
|
127
|
+
);
|
|
128
|
+
} else {
|
|
129
|
+
var args = [a, b, c, d, e, f];
|
|
130
|
+
var argIndex = 0;
|
|
131
|
+
error = new Error(
|
|
132
|
+
format.replace(/%s/g, function() {
|
|
133
|
+
return args[argIndex++];
|
|
134
|
+
})
|
|
135
|
+
);
|
|
136
|
+
error.name = "Invariant Violation";
|
|
137
|
+
}
|
|
138
|
+
error.framesToPop = 1;
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
module2.exports = invariant2;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// node_modules/shallowequal/index.js
|
|
147
|
+
var require_shallowequal = __commonJS({
|
|
148
|
+
"node_modules/shallowequal/index.js"(exports2, module2) {
|
|
149
|
+
"use strict";
|
|
150
|
+
module2.exports = function shallowEqual2(objA, objB, compare, compareContext) {
|
|
151
|
+
var ret = compare ? compare.call(compareContext, objA, objB) : void 0;
|
|
152
|
+
if (ret !== void 0) {
|
|
153
|
+
return !!ret;
|
|
154
|
+
}
|
|
155
|
+
if (objA === objB) {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
if (typeof objA !== "object" || !objA || typeof objB !== "object" || !objB) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
var keysA = Object.keys(objA);
|
|
162
|
+
var keysB = Object.keys(objB);
|
|
163
|
+
if (keysA.length !== keysB.length) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
|
|
167
|
+
for (var idx = 0; idx < keysA.length; idx++) {
|
|
168
|
+
var key = keysA[idx];
|
|
169
|
+
if (!bHasOwnProperty(key)) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
var valueA = objA[key];
|
|
173
|
+
var valueB = objB[key];
|
|
174
|
+
ret = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;
|
|
175
|
+
if (ret === false || ret === void 0 && valueA !== valueB) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return true;
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
|
|
20
184
|
// src/index.ts
|
|
21
185
|
var index_exports = {};
|
|
22
186
|
__export(index_exports, {
|
|
@@ -1028,15 +1192,824 @@ function generateHomepageMetadata(input, config) {
|
|
|
1028
1192
|
}
|
|
1029
1193
|
|
|
1030
1194
|
// src/components/SEOProvider.tsx
|
|
1031
|
-
var
|
|
1032
|
-
|
|
1195
|
+
var import_react5 = require("react");
|
|
1196
|
+
|
|
1197
|
+
// node_modules/react-helmet-async/lib/index.esm.js
|
|
1198
|
+
var import_react = __toESM(require("react"));
|
|
1199
|
+
var import_react_fast_compare = __toESM(require_react_fast_compare());
|
|
1200
|
+
var import_invariant = __toESM(require_invariant());
|
|
1201
|
+
var import_react2 = __toESM(require("react"));
|
|
1202
|
+
var import_react3 = __toESM(require("react"));
|
|
1203
|
+
var import_react4 = require("react");
|
|
1204
|
+
var import_shallowequal = __toESM(require_shallowequal());
|
|
1205
|
+
var TAG_NAMES = /* @__PURE__ */ ((TAG_NAMES2) => {
|
|
1206
|
+
TAG_NAMES2["BASE"] = "base";
|
|
1207
|
+
TAG_NAMES2["BODY"] = "body";
|
|
1208
|
+
TAG_NAMES2["HEAD"] = "head";
|
|
1209
|
+
TAG_NAMES2["HTML"] = "html";
|
|
1210
|
+
TAG_NAMES2["LINK"] = "link";
|
|
1211
|
+
TAG_NAMES2["META"] = "meta";
|
|
1212
|
+
TAG_NAMES2["NOSCRIPT"] = "noscript";
|
|
1213
|
+
TAG_NAMES2["SCRIPT"] = "script";
|
|
1214
|
+
TAG_NAMES2["STYLE"] = "style";
|
|
1215
|
+
TAG_NAMES2["TITLE"] = "title";
|
|
1216
|
+
TAG_NAMES2["FRAGMENT"] = "Symbol(react.fragment)";
|
|
1217
|
+
return TAG_NAMES2;
|
|
1218
|
+
})(TAG_NAMES || {});
|
|
1219
|
+
var SEO_PRIORITY_TAGS = {
|
|
1220
|
+
link: { rel: ["amphtml", "canonical", "alternate"] },
|
|
1221
|
+
script: { type: ["application/ld+json"] },
|
|
1222
|
+
meta: {
|
|
1223
|
+
charset: "",
|
|
1224
|
+
name: ["generator", "robots", "description"],
|
|
1225
|
+
property: [
|
|
1226
|
+
"og:type",
|
|
1227
|
+
"og:title",
|
|
1228
|
+
"og:url",
|
|
1229
|
+
"og:image",
|
|
1230
|
+
"og:image:alt",
|
|
1231
|
+
"og:description",
|
|
1232
|
+
"twitter:url",
|
|
1233
|
+
"twitter:title",
|
|
1234
|
+
"twitter:description",
|
|
1235
|
+
"twitter:image",
|
|
1236
|
+
"twitter:image:alt",
|
|
1237
|
+
"twitter:card",
|
|
1238
|
+
"twitter:site"
|
|
1239
|
+
]
|
|
1240
|
+
}
|
|
1241
|
+
};
|
|
1242
|
+
var VALID_TAG_NAMES = Object.values(TAG_NAMES);
|
|
1243
|
+
var REACT_TAG_MAP = {
|
|
1244
|
+
accesskey: "accessKey",
|
|
1245
|
+
charset: "charSet",
|
|
1246
|
+
class: "className",
|
|
1247
|
+
contenteditable: "contentEditable",
|
|
1248
|
+
contextmenu: "contextMenu",
|
|
1249
|
+
"http-equiv": "httpEquiv",
|
|
1250
|
+
itemprop: "itemProp",
|
|
1251
|
+
tabindex: "tabIndex"
|
|
1252
|
+
};
|
|
1253
|
+
var HTML_TAG_MAP = Object.entries(REACT_TAG_MAP).reduce(
|
|
1254
|
+
(carry, [key, value]) => {
|
|
1255
|
+
carry[value] = key;
|
|
1256
|
+
return carry;
|
|
1257
|
+
},
|
|
1258
|
+
{}
|
|
1259
|
+
);
|
|
1260
|
+
var HELMET_ATTRIBUTE = "data-rh";
|
|
1261
|
+
var HELMET_PROPS = {
|
|
1262
|
+
DEFAULT_TITLE: "defaultTitle",
|
|
1263
|
+
DEFER: "defer",
|
|
1264
|
+
ENCODE_SPECIAL_CHARACTERS: "encodeSpecialCharacters",
|
|
1265
|
+
ON_CHANGE_CLIENT_STATE: "onChangeClientState",
|
|
1266
|
+
TITLE_TEMPLATE: "titleTemplate",
|
|
1267
|
+
PRIORITIZE_SEO_TAGS: "prioritizeSeoTags"
|
|
1268
|
+
};
|
|
1269
|
+
var getInnermostProperty = (propsList, property) => {
|
|
1270
|
+
for (let i = propsList.length - 1; i >= 0; i -= 1) {
|
|
1271
|
+
const props = propsList[i];
|
|
1272
|
+
if (Object.prototype.hasOwnProperty.call(props, property)) {
|
|
1273
|
+
return props[property];
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
return null;
|
|
1277
|
+
};
|
|
1278
|
+
var getTitleFromPropsList = (propsList) => {
|
|
1279
|
+
let innermostTitle = getInnermostProperty(
|
|
1280
|
+
propsList,
|
|
1281
|
+
"title"
|
|
1282
|
+
/* TITLE */
|
|
1283
|
+
);
|
|
1284
|
+
const innermostTemplate = getInnermostProperty(propsList, HELMET_PROPS.TITLE_TEMPLATE);
|
|
1285
|
+
if (Array.isArray(innermostTitle)) {
|
|
1286
|
+
innermostTitle = innermostTitle.join("");
|
|
1287
|
+
}
|
|
1288
|
+
if (innermostTemplate && innermostTitle) {
|
|
1289
|
+
return innermostTemplate.replace(/%s/g, () => innermostTitle);
|
|
1290
|
+
}
|
|
1291
|
+
const innermostDefaultTitle = getInnermostProperty(propsList, HELMET_PROPS.DEFAULT_TITLE);
|
|
1292
|
+
return innermostTitle || innermostDefaultTitle || void 0;
|
|
1293
|
+
};
|
|
1294
|
+
var getOnChangeClientState = (propsList) => getInnermostProperty(propsList, HELMET_PROPS.ON_CHANGE_CLIENT_STATE) || (() => {
|
|
1295
|
+
});
|
|
1296
|
+
var getAttributesFromPropsList = (tagType, propsList) => propsList.filter((props) => typeof props[tagType] !== "undefined").map((props) => props[tagType]).reduce((tagAttrs, current) => ({ ...tagAttrs, ...current }), {});
|
|
1297
|
+
var getBaseTagFromPropsList = (primaryAttributes, propsList) => propsList.filter((props) => typeof props[
|
|
1298
|
+
"base"
|
|
1299
|
+
/* BASE */
|
|
1300
|
+
] !== "undefined").map((props) => props[
|
|
1301
|
+
"base"
|
|
1302
|
+
/* BASE */
|
|
1303
|
+
]).reverse().reduce((innermostBaseTag, tag) => {
|
|
1304
|
+
if (!innermostBaseTag.length) {
|
|
1305
|
+
const keys = Object.keys(tag);
|
|
1306
|
+
for (let i = 0; i < keys.length; i += 1) {
|
|
1307
|
+
const attributeKey = keys[i];
|
|
1308
|
+
const lowerCaseAttributeKey = attributeKey.toLowerCase();
|
|
1309
|
+
if (primaryAttributes.indexOf(lowerCaseAttributeKey) !== -1 && tag[lowerCaseAttributeKey]) {
|
|
1310
|
+
return innermostBaseTag.concat(tag);
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
return innermostBaseTag;
|
|
1315
|
+
}, []);
|
|
1316
|
+
var warn = (msg) => console && typeof console.warn === "function" && console.warn(msg);
|
|
1317
|
+
var getTagsFromPropsList = (tagName, primaryAttributes, propsList) => {
|
|
1318
|
+
const approvedSeenTags = {};
|
|
1319
|
+
return propsList.filter((props) => {
|
|
1320
|
+
if (Array.isArray(props[tagName])) {
|
|
1321
|
+
return true;
|
|
1322
|
+
}
|
|
1323
|
+
if (typeof props[tagName] !== "undefined") {
|
|
1324
|
+
warn(
|
|
1325
|
+
`Helmet: ${tagName} should be of type "Array". Instead found type "${typeof props[tagName]}"`
|
|
1326
|
+
);
|
|
1327
|
+
}
|
|
1328
|
+
return false;
|
|
1329
|
+
}).map((props) => props[tagName]).reverse().reduce((approvedTags, instanceTags) => {
|
|
1330
|
+
const instanceSeenTags = {};
|
|
1331
|
+
instanceTags.filter((tag) => {
|
|
1332
|
+
let primaryAttributeKey;
|
|
1333
|
+
const keys2 = Object.keys(tag);
|
|
1334
|
+
for (let i = 0; i < keys2.length; i += 1) {
|
|
1335
|
+
const attributeKey = keys2[i];
|
|
1336
|
+
const lowerCaseAttributeKey = attributeKey.toLowerCase();
|
|
1337
|
+
if (primaryAttributes.indexOf(lowerCaseAttributeKey) !== -1 && !(primaryAttributeKey === "rel" && tag[primaryAttributeKey].toLowerCase() === "canonical") && !(lowerCaseAttributeKey === "rel" && tag[lowerCaseAttributeKey].toLowerCase() === "stylesheet")) {
|
|
1338
|
+
primaryAttributeKey = lowerCaseAttributeKey;
|
|
1339
|
+
}
|
|
1340
|
+
if (primaryAttributes.indexOf(attributeKey) !== -1 && (attributeKey === "innerHTML" || attributeKey === "cssText" || attributeKey === "itemprop")) {
|
|
1341
|
+
primaryAttributeKey = attributeKey;
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
if (!primaryAttributeKey || !tag[primaryAttributeKey]) {
|
|
1345
|
+
return false;
|
|
1346
|
+
}
|
|
1347
|
+
const value = tag[primaryAttributeKey].toLowerCase();
|
|
1348
|
+
if (!approvedSeenTags[primaryAttributeKey]) {
|
|
1349
|
+
approvedSeenTags[primaryAttributeKey] = {};
|
|
1350
|
+
}
|
|
1351
|
+
if (!instanceSeenTags[primaryAttributeKey]) {
|
|
1352
|
+
instanceSeenTags[primaryAttributeKey] = {};
|
|
1353
|
+
}
|
|
1354
|
+
if (!approvedSeenTags[primaryAttributeKey][value]) {
|
|
1355
|
+
instanceSeenTags[primaryAttributeKey][value] = true;
|
|
1356
|
+
return true;
|
|
1357
|
+
}
|
|
1358
|
+
return false;
|
|
1359
|
+
}).reverse().forEach((tag) => approvedTags.push(tag));
|
|
1360
|
+
const keys = Object.keys(instanceSeenTags);
|
|
1361
|
+
for (let i = 0; i < keys.length; i += 1) {
|
|
1362
|
+
const attributeKey = keys[i];
|
|
1363
|
+
const tagUnion = {
|
|
1364
|
+
...approvedSeenTags[attributeKey],
|
|
1365
|
+
...instanceSeenTags[attributeKey]
|
|
1366
|
+
};
|
|
1367
|
+
approvedSeenTags[attributeKey] = tagUnion;
|
|
1368
|
+
}
|
|
1369
|
+
return approvedTags;
|
|
1370
|
+
}, []).reverse();
|
|
1371
|
+
};
|
|
1372
|
+
var getAnyTrueFromPropsList = (propsList, checkedTag) => {
|
|
1373
|
+
if (Array.isArray(propsList) && propsList.length) {
|
|
1374
|
+
for (let index = 0; index < propsList.length; index += 1) {
|
|
1375
|
+
const prop = propsList[index];
|
|
1376
|
+
if (prop[checkedTag]) {
|
|
1377
|
+
return true;
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
return false;
|
|
1382
|
+
};
|
|
1383
|
+
var reducePropsToState = (propsList) => ({
|
|
1384
|
+
baseTag: getBaseTagFromPropsList([
|
|
1385
|
+
"href"
|
|
1386
|
+
/* HREF */
|
|
1387
|
+
], propsList),
|
|
1388
|
+
bodyAttributes: getAttributesFromPropsList("bodyAttributes", propsList),
|
|
1389
|
+
defer: getInnermostProperty(propsList, HELMET_PROPS.DEFER),
|
|
1390
|
+
encode: getInnermostProperty(propsList, HELMET_PROPS.ENCODE_SPECIAL_CHARACTERS),
|
|
1391
|
+
htmlAttributes: getAttributesFromPropsList("htmlAttributes", propsList),
|
|
1392
|
+
linkTags: getTagsFromPropsList(
|
|
1393
|
+
"link",
|
|
1394
|
+
[
|
|
1395
|
+
"rel",
|
|
1396
|
+
"href"
|
|
1397
|
+
/* HREF */
|
|
1398
|
+
],
|
|
1399
|
+
propsList
|
|
1400
|
+
),
|
|
1401
|
+
metaTags: getTagsFromPropsList(
|
|
1402
|
+
"meta",
|
|
1403
|
+
[
|
|
1404
|
+
"name",
|
|
1405
|
+
"charset",
|
|
1406
|
+
"http-equiv",
|
|
1407
|
+
"property",
|
|
1408
|
+
"itemprop"
|
|
1409
|
+
/* ITEM_PROP */
|
|
1410
|
+
],
|
|
1411
|
+
propsList
|
|
1412
|
+
),
|
|
1413
|
+
noscriptTags: getTagsFromPropsList("noscript", [
|
|
1414
|
+
"innerHTML"
|
|
1415
|
+
/* INNER_HTML */
|
|
1416
|
+
], propsList),
|
|
1417
|
+
onChangeClientState: getOnChangeClientState(propsList),
|
|
1418
|
+
scriptTags: getTagsFromPropsList(
|
|
1419
|
+
"script",
|
|
1420
|
+
[
|
|
1421
|
+
"src",
|
|
1422
|
+
"innerHTML"
|
|
1423
|
+
/* INNER_HTML */
|
|
1424
|
+
],
|
|
1425
|
+
propsList
|
|
1426
|
+
),
|
|
1427
|
+
styleTags: getTagsFromPropsList("style", [
|
|
1428
|
+
"cssText"
|
|
1429
|
+
/* CSS_TEXT */
|
|
1430
|
+
], propsList),
|
|
1431
|
+
title: getTitleFromPropsList(propsList),
|
|
1432
|
+
titleAttributes: getAttributesFromPropsList("titleAttributes", propsList),
|
|
1433
|
+
prioritizeSeoTags: getAnyTrueFromPropsList(propsList, HELMET_PROPS.PRIORITIZE_SEO_TAGS)
|
|
1434
|
+
});
|
|
1435
|
+
var flattenArray = (possibleArray) => Array.isArray(possibleArray) ? possibleArray.join("") : possibleArray;
|
|
1436
|
+
var checkIfPropsMatch = (props, toMatch) => {
|
|
1437
|
+
const keys = Object.keys(props);
|
|
1438
|
+
for (let i = 0; i < keys.length; i += 1) {
|
|
1439
|
+
if (toMatch[keys[i]] && toMatch[keys[i]].includes(props[keys[i]])) {
|
|
1440
|
+
return true;
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
return false;
|
|
1444
|
+
};
|
|
1445
|
+
var prioritizer = (elementsList, propsToMatch) => {
|
|
1446
|
+
if (Array.isArray(elementsList)) {
|
|
1447
|
+
return elementsList.reduce(
|
|
1448
|
+
(acc, elementAttrs) => {
|
|
1449
|
+
if (checkIfPropsMatch(elementAttrs, propsToMatch)) {
|
|
1450
|
+
acc.priority.push(elementAttrs);
|
|
1451
|
+
} else {
|
|
1452
|
+
acc.default.push(elementAttrs);
|
|
1453
|
+
}
|
|
1454
|
+
return acc;
|
|
1455
|
+
},
|
|
1456
|
+
{ priority: [], default: [] }
|
|
1457
|
+
);
|
|
1458
|
+
}
|
|
1459
|
+
return { default: elementsList, priority: [] };
|
|
1460
|
+
};
|
|
1461
|
+
var without = (obj, key) => {
|
|
1462
|
+
return {
|
|
1463
|
+
...obj,
|
|
1464
|
+
[key]: void 0
|
|
1465
|
+
};
|
|
1466
|
+
};
|
|
1467
|
+
var SELF_CLOSING_TAGS = [
|
|
1468
|
+
"noscript",
|
|
1469
|
+
"script",
|
|
1470
|
+
"style"
|
|
1471
|
+
/* STYLE */
|
|
1472
|
+
];
|
|
1473
|
+
var encodeSpecialCharacters = (str, encode = true) => {
|
|
1474
|
+
if (encode === false) {
|
|
1475
|
+
return String(str);
|
|
1476
|
+
}
|
|
1477
|
+
return String(str).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1478
|
+
};
|
|
1479
|
+
var generateElementAttributesAsString = (attributes) => Object.keys(attributes).reduce((str, key) => {
|
|
1480
|
+
const attr = typeof attributes[key] !== "undefined" ? `${key}="${attributes[key]}"` : `${key}`;
|
|
1481
|
+
return str ? `${str} ${attr}` : attr;
|
|
1482
|
+
}, "");
|
|
1483
|
+
var generateTitleAsString = (type, title, attributes, encode) => {
|
|
1484
|
+
const attributeString = generateElementAttributesAsString(attributes);
|
|
1485
|
+
const flattenedTitle = flattenArray(title);
|
|
1486
|
+
return attributeString ? `<${type} ${HELMET_ATTRIBUTE}="true" ${attributeString}>${encodeSpecialCharacters(
|
|
1487
|
+
flattenedTitle,
|
|
1488
|
+
encode
|
|
1489
|
+
)}</${type}>` : `<${type} ${HELMET_ATTRIBUTE}="true">${encodeSpecialCharacters(
|
|
1490
|
+
flattenedTitle,
|
|
1491
|
+
encode
|
|
1492
|
+
)}</${type}>`;
|
|
1493
|
+
};
|
|
1494
|
+
var generateTagsAsString = (type, tags, encode = true) => tags.reduce((str, t) => {
|
|
1495
|
+
const tag = t;
|
|
1496
|
+
const attributeHtml = Object.keys(tag).filter(
|
|
1497
|
+
(attribute) => !(attribute === "innerHTML" || attribute === "cssText")
|
|
1498
|
+
).reduce((string, attribute) => {
|
|
1499
|
+
const attr = typeof tag[attribute] === "undefined" ? attribute : `${attribute}="${encodeSpecialCharacters(tag[attribute], encode)}"`;
|
|
1500
|
+
return string ? `${string} ${attr}` : attr;
|
|
1501
|
+
}, "");
|
|
1502
|
+
const tagContent = tag.innerHTML || tag.cssText || "";
|
|
1503
|
+
const isSelfClosing = SELF_CLOSING_TAGS.indexOf(type) === -1;
|
|
1504
|
+
return `${str}<${type} ${HELMET_ATTRIBUTE}="true" ${attributeHtml}${isSelfClosing ? `/>` : `>${tagContent}</${type}>`}`;
|
|
1505
|
+
}, "");
|
|
1506
|
+
var convertElementAttributesToReactProps = (attributes, initProps = {}) => Object.keys(attributes).reduce((obj, key) => {
|
|
1507
|
+
const mapped = REACT_TAG_MAP[key];
|
|
1508
|
+
obj[mapped || key] = attributes[key];
|
|
1509
|
+
return obj;
|
|
1510
|
+
}, initProps);
|
|
1511
|
+
var generateTitleAsReactComponent = (_type, title, attributes) => {
|
|
1512
|
+
const initProps = {
|
|
1513
|
+
key: title,
|
|
1514
|
+
[HELMET_ATTRIBUTE]: true
|
|
1515
|
+
};
|
|
1516
|
+
const props = convertElementAttributesToReactProps(attributes, initProps);
|
|
1517
|
+
return [import_react3.default.createElement("title", props, title)];
|
|
1518
|
+
};
|
|
1519
|
+
var generateTagsAsReactComponent = (type, tags) => tags.map((tag, i) => {
|
|
1520
|
+
const mappedTag = {
|
|
1521
|
+
key: i,
|
|
1522
|
+
[HELMET_ATTRIBUTE]: true
|
|
1523
|
+
};
|
|
1524
|
+
Object.keys(tag).forEach((attribute) => {
|
|
1525
|
+
const mapped = REACT_TAG_MAP[attribute];
|
|
1526
|
+
const mappedAttribute = mapped || attribute;
|
|
1527
|
+
if (mappedAttribute === "innerHTML" || mappedAttribute === "cssText") {
|
|
1528
|
+
const content = tag.innerHTML || tag.cssText;
|
|
1529
|
+
mappedTag.dangerouslySetInnerHTML = { __html: content };
|
|
1530
|
+
} else {
|
|
1531
|
+
mappedTag[mappedAttribute] = tag[attribute];
|
|
1532
|
+
}
|
|
1533
|
+
});
|
|
1534
|
+
return import_react3.default.createElement(type, mappedTag);
|
|
1535
|
+
});
|
|
1536
|
+
var getMethodsForTag = (type, tags, encode = true) => {
|
|
1537
|
+
switch (type) {
|
|
1538
|
+
case "title":
|
|
1539
|
+
return {
|
|
1540
|
+
toComponent: () => generateTitleAsReactComponent(type, tags.title, tags.titleAttributes),
|
|
1541
|
+
toString: () => generateTitleAsString(type, tags.title, tags.titleAttributes, encode)
|
|
1542
|
+
};
|
|
1543
|
+
case "bodyAttributes":
|
|
1544
|
+
case "htmlAttributes":
|
|
1545
|
+
return {
|
|
1546
|
+
toComponent: () => convertElementAttributesToReactProps(tags),
|
|
1547
|
+
toString: () => generateElementAttributesAsString(tags)
|
|
1548
|
+
};
|
|
1549
|
+
default:
|
|
1550
|
+
return {
|
|
1551
|
+
toComponent: () => generateTagsAsReactComponent(type, tags),
|
|
1552
|
+
toString: () => generateTagsAsString(type, tags, encode)
|
|
1553
|
+
};
|
|
1554
|
+
}
|
|
1555
|
+
};
|
|
1556
|
+
var getPriorityMethods = ({ metaTags, linkTags, scriptTags, encode }) => {
|
|
1557
|
+
const meta = prioritizer(metaTags, SEO_PRIORITY_TAGS.meta);
|
|
1558
|
+
const link = prioritizer(linkTags, SEO_PRIORITY_TAGS.link);
|
|
1559
|
+
const script = prioritizer(scriptTags, SEO_PRIORITY_TAGS.script);
|
|
1560
|
+
const priorityMethods = {
|
|
1561
|
+
toComponent: () => [
|
|
1562
|
+
...generateTagsAsReactComponent("meta", meta.priority),
|
|
1563
|
+
...generateTagsAsReactComponent("link", link.priority),
|
|
1564
|
+
...generateTagsAsReactComponent("script", script.priority)
|
|
1565
|
+
],
|
|
1566
|
+
toString: () => (
|
|
1567
|
+
// generate all the tags as strings and concatenate them
|
|
1568
|
+
`${getMethodsForTag("meta", meta.priority, encode)} ${getMethodsForTag(
|
|
1569
|
+
"link",
|
|
1570
|
+
link.priority,
|
|
1571
|
+
encode
|
|
1572
|
+
)} ${getMethodsForTag("script", script.priority, encode)}`
|
|
1573
|
+
)
|
|
1574
|
+
};
|
|
1575
|
+
return {
|
|
1576
|
+
priorityMethods,
|
|
1577
|
+
metaTags: meta.default,
|
|
1578
|
+
linkTags: link.default,
|
|
1579
|
+
scriptTags: script.default
|
|
1580
|
+
};
|
|
1581
|
+
};
|
|
1582
|
+
var mapStateOnServer = (props) => {
|
|
1583
|
+
const {
|
|
1584
|
+
baseTag,
|
|
1585
|
+
bodyAttributes,
|
|
1586
|
+
encode = true,
|
|
1587
|
+
htmlAttributes,
|
|
1588
|
+
noscriptTags,
|
|
1589
|
+
styleTags,
|
|
1590
|
+
title = "",
|
|
1591
|
+
titleAttributes,
|
|
1592
|
+
prioritizeSeoTags
|
|
1593
|
+
} = props;
|
|
1594
|
+
let { linkTags, metaTags, scriptTags } = props;
|
|
1595
|
+
let priorityMethods = {
|
|
1596
|
+
toComponent: () => {
|
|
1597
|
+
},
|
|
1598
|
+
toString: () => ""
|
|
1599
|
+
};
|
|
1600
|
+
if (prioritizeSeoTags) {
|
|
1601
|
+
({ priorityMethods, linkTags, metaTags, scriptTags } = getPriorityMethods(props));
|
|
1602
|
+
}
|
|
1603
|
+
return {
|
|
1604
|
+
priority: priorityMethods,
|
|
1605
|
+
base: getMethodsForTag("base", baseTag, encode),
|
|
1606
|
+
bodyAttributes: getMethodsForTag("bodyAttributes", bodyAttributes, encode),
|
|
1607
|
+
htmlAttributes: getMethodsForTag("htmlAttributes", htmlAttributes, encode),
|
|
1608
|
+
link: getMethodsForTag("link", linkTags, encode),
|
|
1609
|
+
meta: getMethodsForTag("meta", metaTags, encode),
|
|
1610
|
+
noscript: getMethodsForTag("noscript", noscriptTags, encode),
|
|
1611
|
+
script: getMethodsForTag("script", scriptTags, encode),
|
|
1612
|
+
style: getMethodsForTag("style", styleTags, encode),
|
|
1613
|
+
title: getMethodsForTag("title", { title, titleAttributes }, encode)
|
|
1614
|
+
};
|
|
1615
|
+
};
|
|
1616
|
+
var server_default = mapStateOnServer;
|
|
1617
|
+
var instances = [];
|
|
1618
|
+
var isDocument = !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
1619
|
+
var HelmetData = class {
|
|
1620
|
+
instances = [];
|
|
1621
|
+
canUseDOM = isDocument;
|
|
1622
|
+
context;
|
|
1623
|
+
value = {
|
|
1624
|
+
setHelmet: (serverState) => {
|
|
1625
|
+
this.context.helmet = serverState;
|
|
1626
|
+
},
|
|
1627
|
+
helmetInstances: {
|
|
1628
|
+
get: () => this.canUseDOM ? instances : this.instances,
|
|
1629
|
+
add: (instance) => {
|
|
1630
|
+
(this.canUseDOM ? instances : this.instances).push(instance);
|
|
1631
|
+
},
|
|
1632
|
+
remove: (instance) => {
|
|
1633
|
+
const index = (this.canUseDOM ? instances : this.instances).indexOf(instance);
|
|
1634
|
+
(this.canUseDOM ? instances : this.instances).splice(index, 1);
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
};
|
|
1638
|
+
constructor(context, canUseDOM) {
|
|
1639
|
+
this.context = context;
|
|
1640
|
+
this.canUseDOM = canUseDOM || false;
|
|
1641
|
+
if (!canUseDOM) {
|
|
1642
|
+
context.helmet = server_default({
|
|
1643
|
+
baseTag: [],
|
|
1644
|
+
bodyAttributes: {},
|
|
1645
|
+
encodeSpecialCharacters: true,
|
|
1646
|
+
htmlAttributes: {},
|
|
1647
|
+
linkTags: [],
|
|
1648
|
+
metaTags: [],
|
|
1649
|
+
noscriptTags: [],
|
|
1650
|
+
scriptTags: [],
|
|
1651
|
+
styleTags: [],
|
|
1652
|
+
title: "",
|
|
1653
|
+
titleAttributes: {}
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
};
|
|
1658
|
+
var defaultValue = {};
|
|
1659
|
+
var Context = import_react2.default.createContext(defaultValue);
|
|
1660
|
+
var HelmetProvider = class _HelmetProvider extends import_react2.Component {
|
|
1661
|
+
static canUseDOM = isDocument;
|
|
1662
|
+
helmetData;
|
|
1663
|
+
constructor(props) {
|
|
1664
|
+
super(props);
|
|
1665
|
+
this.helmetData = new HelmetData(this.props.context || {}, _HelmetProvider.canUseDOM);
|
|
1666
|
+
}
|
|
1667
|
+
render() {
|
|
1668
|
+
return /* @__PURE__ */ import_react2.default.createElement(Context.Provider, { value: this.helmetData.value }, this.props.children);
|
|
1669
|
+
}
|
|
1670
|
+
};
|
|
1671
|
+
var updateTags = (type, tags) => {
|
|
1672
|
+
const headElement = document.head || document.querySelector(
|
|
1673
|
+
"head"
|
|
1674
|
+
/* HEAD */
|
|
1675
|
+
);
|
|
1676
|
+
const tagNodes = headElement.querySelectorAll(`${type}[${HELMET_ATTRIBUTE}]`);
|
|
1677
|
+
const oldTags = [].slice.call(tagNodes);
|
|
1678
|
+
const newTags = [];
|
|
1679
|
+
let indexToDelete;
|
|
1680
|
+
if (tags && tags.length) {
|
|
1681
|
+
tags.forEach((tag) => {
|
|
1682
|
+
const newElement = document.createElement(type);
|
|
1683
|
+
for (const attribute in tag) {
|
|
1684
|
+
if (Object.prototype.hasOwnProperty.call(tag, attribute)) {
|
|
1685
|
+
if (attribute === "innerHTML") {
|
|
1686
|
+
newElement.innerHTML = tag.innerHTML;
|
|
1687
|
+
} else if (attribute === "cssText") {
|
|
1688
|
+
if (newElement.styleSheet) {
|
|
1689
|
+
newElement.styleSheet.cssText = tag.cssText;
|
|
1690
|
+
} else {
|
|
1691
|
+
newElement.appendChild(document.createTextNode(tag.cssText));
|
|
1692
|
+
}
|
|
1693
|
+
} else {
|
|
1694
|
+
const attr = attribute;
|
|
1695
|
+
const value = typeof tag[attr] === "undefined" ? "" : tag[attr];
|
|
1696
|
+
newElement.setAttribute(attribute, value);
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
newElement.setAttribute(HELMET_ATTRIBUTE, "true");
|
|
1701
|
+
if (oldTags.some((existingTag, index) => {
|
|
1702
|
+
indexToDelete = index;
|
|
1703
|
+
return newElement.isEqualNode(existingTag);
|
|
1704
|
+
})) {
|
|
1705
|
+
oldTags.splice(indexToDelete, 1);
|
|
1706
|
+
} else {
|
|
1707
|
+
newTags.push(newElement);
|
|
1708
|
+
}
|
|
1709
|
+
});
|
|
1710
|
+
}
|
|
1711
|
+
oldTags.forEach((tag) => tag.parentNode?.removeChild(tag));
|
|
1712
|
+
newTags.forEach((tag) => headElement.appendChild(tag));
|
|
1713
|
+
return {
|
|
1714
|
+
oldTags,
|
|
1715
|
+
newTags
|
|
1716
|
+
};
|
|
1717
|
+
};
|
|
1718
|
+
var updateAttributes = (tagName, attributes) => {
|
|
1719
|
+
const elementTag = document.getElementsByTagName(tagName)[0];
|
|
1720
|
+
if (!elementTag) {
|
|
1721
|
+
return;
|
|
1722
|
+
}
|
|
1723
|
+
const helmetAttributeString = elementTag.getAttribute(HELMET_ATTRIBUTE);
|
|
1724
|
+
const helmetAttributes = helmetAttributeString ? helmetAttributeString.split(",") : [];
|
|
1725
|
+
const attributesToRemove = [...helmetAttributes];
|
|
1726
|
+
const attributeKeys = Object.keys(attributes);
|
|
1727
|
+
for (const attribute of attributeKeys) {
|
|
1728
|
+
const value = attributes[attribute] || "";
|
|
1729
|
+
if (elementTag.getAttribute(attribute) !== value) {
|
|
1730
|
+
elementTag.setAttribute(attribute, value);
|
|
1731
|
+
}
|
|
1732
|
+
if (helmetAttributes.indexOf(attribute) === -1) {
|
|
1733
|
+
helmetAttributes.push(attribute);
|
|
1734
|
+
}
|
|
1735
|
+
const indexToSave = attributesToRemove.indexOf(attribute);
|
|
1736
|
+
if (indexToSave !== -1) {
|
|
1737
|
+
attributesToRemove.splice(indexToSave, 1);
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
for (let i = attributesToRemove.length - 1; i >= 0; i -= 1) {
|
|
1741
|
+
elementTag.removeAttribute(attributesToRemove[i]);
|
|
1742
|
+
}
|
|
1743
|
+
if (helmetAttributes.length === attributesToRemove.length) {
|
|
1744
|
+
elementTag.removeAttribute(HELMET_ATTRIBUTE);
|
|
1745
|
+
} else if (elementTag.getAttribute(HELMET_ATTRIBUTE) !== attributeKeys.join(",")) {
|
|
1746
|
+
elementTag.setAttribute(HELMET_ATTRIBUTE, attributeKeys.join(","));
|
|
1747
|
+
}
|
|
1748
|
+
};
|
|
1749
|
+
var updateTitle = (title, attributes) => {
|
|
1750
|
+
if (typeof title !== "undefined" && document.title !== title) {
|
|
1751
|
+
document.title = flattenArray(title);
|
|
1752
|
+
}
|
|
1753
|
+
updateAttributes("title", attributes);
|
|
1754
|
+
};
|
|
1755
|
+
var commitTagChanges = (newState, cb) => {
|
|
1756
|
+
const {
|
|
1757
|
+
baseTag,
|
|
1758
|
+
bodyAttributes,
|
|
1759
|
+
htmlAttributes,
|
|
1760
|
+
linkTags,
|
|
1761
|
+
metaTags,
|
|
1762
|
+
noscriptTags,
|
|
1763
|
+
onChangeClientState,
|
|
1764
|
+
scriptTags,
|
|
1765
|
+
styleTags,
|
|
1766
|
+
title,
|
|
1767
|
+
titleAttributes
|
|
1768
|
+
} = newState;
|
|
1769
|
+
updateAttributes("body", bodyAttributes);
|
|
1770
|
+
updateAttributes("html", htmlAttributes);
|
|
1771
|
+
updateTitle(title, titleAttributes);
|
|
1772
|
+
const tagUpdates = {
|
|
1773
|
+
baseTag: updateTags("base", baseTag),
|
|
1774
|
+
linkTags: updateTags("link", linkTags),
|
|
1775
|
+
metaTags: updateTags("meta", metaTags),
|
|
1776
|
+
noscriptTags: updateTags("noscript", noscriptTags),
|
|
1777
|
+
scriptTags: updateTags("script", scriptTags),
|
|
1778
|
+
styleTags: updateTags("style", styleTags)
|
|
1779
|
+
};
|
|
1780
|
+
const addedTags = {};
|
|
1781
|
+
const removedTags = {};
|
|
1782
|
+
Object.keys(tagUpdates).forEach((tagType) => {
|
|
1783
|
+
const { newTags, oldTags } = tagUpdates[tagType];
|
|
1784
|
+
if (newTags.length) {
|
|
1785
|
+
addedTags[tagType] = newTags;
|
|
1786
|
+
}
|
|
1787
|
+
if (oldTags.length) {
|
|
1788
|
+
removedTags[tagType] = tagUpdates[tagType].oldTags;
|
|
1789
|
+
}
|
|
1790
|
+
});
|
|
1791
|
+
if (cb) {
|
|
1792
|
+
cb();
|
|
1793
|
+
}
|
|
1794
|
+
onChangeClientState(newState, addedTags, removedTags);
|
|
1795
|
+
};
|
|
1796
|
+
var _helmetCallback = null;
|
|
1797
|
+
var handleStateChangeOnClient = (newState) => {
|
|
1798
|
+
if (_helmetCallback) {
|
|
1799
|
+
cancelAnimationFrame(_helmetCallback);
|
|
1800
|
+
}
|
|
1801
|
+
if (newState.defer) {
|
|
1802
|
+
_helmetCallback = requestAnimationFrame(() => {
|
|
1803
|
+
commitTagChanges(newState, () => {
|
|
1804
|
+
_helmetCallback = null;
|
|
1805
|
+
});
|
|
1806
|
+
});
|
|
1807
|
+
} else {
|
|
1808
|
+
commitTagChanges(newState);
|
|
1809
|
+
_helmetCallback = null;
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1812
|
+
var client_default = handleStateChangeOnClient;
|
|
1813
|
+
var HelmetDispatcher = class extends import_react4.Component {
|
|
1814
|
+
rendered = false;
|
|
1815
|
+
shouldComponentUpdate(nextProps) {
|
|
1816
|
+
return !(0, import_shallowequal.default)(nextProps, this.props);
|
|
1817
|
+
}
|
|
1818
|
+
componentDidUpdate() {
|
|
1819
|
+
this.emitChange();
|
|
1820
|
+
}
|
|
1821
|
+
componentWillUnmount() {
|
|
1822
|
+
const { helmetInstances } = this.props.context;
|
|
1823
|
+
helmetInstances.remove(this);
|
|
1824
|
+
this.emitChange();
|
|
1825
|
+
}
|
|
1826
|
+
emitChange() {
|
|
1827
|
+
const { helmetInstances, setHelmet } = this.props.context;
|
|
1828
|
+
let serverState = null;
|
|
1829
|
+
const state = reducePropsToState(
|
|
1830
|
+
helmetInstances.get().map((instance) => {
|
|
1831
|
+
const props = { ...instance.props };
|
|
1832
|
+
delete props.context;
|
|
1833
|
+
return props;
|
|
1834
|
+
})
|
|
1835
|
+
);
|
|
1836
|
+
if (HelmetProvider.canUseDOM) {
|
|
1837
|
+
client_default(state);
|
|
1838
|
+
} else if (server_default) {
|
|
1839
|
+
serverState = server_default(state);
|
|
1840
|
+
}
|
|
1841
|
+
setHelmet(serverState);
|
|
1842
|
+
}
|
|
1843
|
+
// componentWillMount will be deprecated
|
|
1844
|
+
// for SSR, initialize on first render
|
|
1845
|
+
// constructor is also unsafe in StrictMode
|
|
1846
|
+
init() {
|
|
1847
|
+
if (this.rendered) {
|
|
1848
|
+
return;
|
|
1849
|
+
}
|
|
1850
|
+
this.rendered = true;
|
|
1851
|
+
const { helmetInstances } = this.props.context;
|
|
1852
|
+
helmetInstances.add(this);
|
|
1853
|
+
this.emitChange();
|
|
1854
|
+
}
|
|
1855
|
+
render() {
|
|
1856
|
+
this.init();
|
|
1857
|
+
return null;
|
|
1858
|
+
}
|
|
1859
|
+
};
|
|
1860
|
+
var Helmet = class extends import_react.Component {
|
|
1861
|
+
static defaultProps = {
|
|
1862
|
+
defer: true,
|
|
1863
|
+
encodeSpecialCharacters: true,
|
|
1864
|
+
prioritizeSeoTags: false
|
|
1865
|
+
};
|
|
1866
|
+
shouldComponentUpdate(nextProps) {
|
|
1867
|
+
return !(0, import_react_fast_compare.default)(without(this.props, "helmetData"), without(nextProps, "helmetData"));
|
|
1868
|
+
}
|
|
1869
|
+
mapNestedChildrenToProps(child, nestedChildren) {
|
|
1870
|
+
if (!nestedChildren) {
|
|
1871
|
+
return null;
|
|
1872
|
+
}
|
|
1873
|
+
switch (child.type) {
|
|
1874
|
+
case "script":
|
|
1875
|
+
case "noscript":
|
|
1876
|
+
return {
|
|
1877
|
+
innerHTML: nestedChildren
|
|
1878
|
+
};
|
|
1879
|
+
case "style":
|
|
1880
|
+
return {
|
|
1881
|
+
cssText: nestedChildren
|
|
1882
|
+
};
|
|
1883
|
+
default:
|
|
1884
|
+
throw new Error(
|
|
1885
|
+
`<${child.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`
|
|
1886
|
+
);
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
flattenArrayTypeChildren(child, arrayTypeChildren, newChildProps, nestedChildren) {
|
|
1890
|
+
return {
|
|
1891
|
+
...arrayTypeChildren,
|
|
1892
|
+
[child.type]: [
|
|
1893
|
+
...arrayTypeChildren[child.type] || [],
|
|
1894
|
+
{
|
|
1895
|
+
...newChildProps,
|
|
1896
|
+
...this.mapNestedChildrenToProps(child, nestedChildren)
|
|
1897
|
+
}
|
|
1898
|
+
]
|
|
1899
|
+
};
|
|
1900
|
+
}
|
|
1901
|
+
mapObjectTypeChildren(child, newProps, newChildProps, nestedChildren) {
|
|
1902
|
+
switch (child.type) {
|
|
1903
|
+
case "title":
|
|
1904
|
+
return {
|
|
1905
|
+
...newProps,
|
|
1906
|
+
[child.type]: nestedChildren,
|
|
1907
|
+
titleAttributes: { ...newChildProps }
|
|
1908
|
+
};
|
|
1909
|
+
case "body":
|
|
1910
|
+
return {
|
|
1911
|
+
...newProps,
|
|
1912
|
+
bodyAttributes: { ...newChildProps }
|
|
1913
|
+
};
|
|
1914
|
+
case "html":
|
|
1915
|
+
return {
|
|
1916
|
+
...newProps,
|
|
1917
|
+
htmlAttributes: { ...newChildProps }
|
|
1918
|
+
};
|
|
1919
|
+
default:
|
|
1920
|
+
return {
|
|
1921
|
+
...newProps,
|
|
1922
|
+
[child.type]: { ...newChildProps }
|
|
1923
|
+
};
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
mapArrayTypeChildrenToProps(arrayTypeChildren, newProps) {
|
|
1927
|
+
let newFlattenedProps = { ...newProps };
|
|
1928
|
+
Object.keys(arrayTypeChildren).forEach((arrayChildName) => {
|
|
1929
|
+
newFlattenedProps = {
|
|
1930
|
+
...newFlattenedProps,
|
|
1931
|
+
[arrayChildName]: arrayTypeChildren[arrayChildName]
|
|
1932
|
+
};
|
|
1933
|
+
});
|
|
1934
|
+
return newFlattenedProps;
|
|
1935
|
+
}
|
|
1936
|
+
warnOnInvalidChildren(child, nestedChildren) {
|
|
1937
|
+
(0, import_invariant.default)(
|
|
1938
|
+
VALID_TAG_NAMES.some((name) => child.type === name),
|
|
1939
|
+
typeof child.type === "function" ? `You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.` : `Only elements types ${VALID_TAG_NAMES.join(
|
|
1940
|
+
", "
|
|
1941
|
+
)} are allowed. Helmet does not support rendering <${child.type}> elements. Refer to our API for more information.`
|
|
1942
|
+
);
|
|
1943
|
+
(0, import_invariant.default)(
|
|
1944
|
+
!nestedChildren || typeof nestedChildren === "string" || Array.isArray(nestedChildren) && !nestedChildren.some((nestedChild) => typeof nestedChild !== "string"),
|
|
1945
|
+
`Helmet expects a string as a child of <${child.type}>. Did you forget to wrap your children in braces? ( <${child.type}>{\`\`}</${child.type}> ) Refer to our API for more information.`
|
|
1946
|
+
);
|
|
1947
|
+
return true;
|
|
1948
|
+
}
|
|
1949
|
+
mapChildrenToProps(children, newProps) {
|
|
1950
|
+
let arrayTypeChildren = {};
|
|
1951
|
+
import_react.default.Children.forEach(children, (child) => {
|
|
1952
|
+
if (!child || !child.props) {
|
|
1953
|
+
return;
|
|
1954
|
+
}
|
|
1955
|
+
const { children: nestedChildren, ...childProps } = child.props;
|
|
1956
|
+
const newChildProps = Object.keys(childProps).reduce((obj, key) => {
|
|
1957
|
+
obj[HTML_TAG_MAP[key] || key] = childProps[key];
|
|
1958
|
+
return obj;
|
|
1959
|
+
}, {});
|
|
1960
|
+
let { type } = child;
|
|
1961
|
+
if (typeof type === "symbol") {
|
|
1962
|
+
type = type.toString();
|
|
1963
|
+
} else {
|
|
1964
|
+
this.warnOnInvalidChildren(child, nestedChildren);
|
|
1965
|
+
}
|
|
1966
|
+
switch (type) {
|
|
1967
|
+
case "Symbol(react.fragment)":
|
|
1968
|
+
newProps = this.mapChildrenToProps(nestedChildren, newProps);
|
|
1969
|
+
break;
|
|
1970
|
+
case "link":
|
|
1971
|
+
case "meta":
|
|
1972
|
+
case "noscript":
|
|
1973
|
+
case "script":
|
|
1974
|
+
case "style":
|
|
1975
|
+
arrayTypeChildren = this.flattenArrayTypeChildren(
|
|
1976
|
+
child,
|
|
1977
|
+
arrayTypeChildren,
|
|
1978
|
+
newChildProps,
|
|
1979
|
+
nestedChildren
|
|
1980
|
+
);
|
|
1981
|
+
break;
|
|
1982
|
+
default:
|
|
1983
|
+
newProps = this.mapObjectTypeChildren(child, newProps, newChildProps, nestedChildren);
|
|
1984
|
+
break;
|
|
1985
|
+
}
|
|
1986
|
+
});
|
|
1987
|
+
return this.mapArrayTypeChildrenToProps(arrayTypeChildren, newProps);
|
|
1988
|
+
}
|
|
1989
|
+
render() {
|
|
1990
|
+
const { children, ...props } = this.props;
|
|
1991
|
+
let newProps = { ...props };
|
|
1992
|
+
let { helmetData } = props;
|
|
1993
|
+
if (children) {
|
|
1994
|
+
newProps = this.mapChildrenToProps(children, newProps);
|
|
1995
|
+
}
|
|
1996
|
+
if (helmetData && !(helmetData instanceof HelmetData)) {
|
|
1997
|
+
const data = helmetData;
|
|
1998
|
+
helmetData = new HelmetData(data.context, true);
|
|
1999
|
+
delete newProps.helmetData;
|
|
2000
|
+
}
|
|
2001
|
+
return helmetData ? /* @__PURE__ */ import_react.default.createElement(HelmetDispatcher, { ...newProps, context: helmetData.value }) : /* @__PURE__ */ import_react.default.createElement(Context.Consumer, null, (context) => /* @__PURE__ */ import_react.default.createElement(HelmetDispatcher, { ...newProps, context }));
|
|
2002
|
+
}
|
|
2003
|
+
};
|
|
2004
|
+
|
|
2005
|
+
// src/components/SEOProvider.tsx
|
|
1033
2006
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1034
|
-
var SEOContext = (0,
|
|
2007
|
+
var SEOContext = (0, import_react5.createContext)(void 0);
|
|
1035
2008
|
var SEOProvider = ({ config, children, helmetContext }) => {
|
|
1036
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SEOContext.Provider, { value: { config }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2009
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SEOContext.Provider, { value: { config }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(HelmetProvider, { context: helmetContext, children }) });
|
|
1037
2010
|
};
|
|
1038
2011
|
var useSEOConfig = () => {
|
|
1039
|
-
const context = (0,
|
|
2012
|
+
const context = (0, import_react5.useContext)(SEOContext);
|
|
1040
2013
|
if (!context) {
|
|
1041
2014
|
throw new Error("useSEOConfig must be used within an SEOProvider");
|
|
1042
2015
|
}
|
|
@@ -1044,7 +2017,6 @@ var useSEOConfig = () => {
|
|
|
1044
2017
|
};
|
|
1045
2018
|
|
|
1046
2019
|
// src/components/SEO.tsx
|
|
1047
|
-
var import_react_helmet_async2 = require("react-helmet-async");
|
|
1048
2020
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1049
2021
|
var SEO = (props) => {
|
|
1050
2022
|
const config = useSEOConfig();
|
|
@@ -1124,7 +2096,7 @@ var SEO = (props) => {
|
|
|
1124
2096
|
schemas.push(props.schema);
|
|
1125
2097
|
}
|
|
1126
2098
|
}
|
|
1127
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2099
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Helmet, { children: [
|
|
1128
2100
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("title", { children: title }),
|
|
1129
2101
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("meta", { name: "description", content: description }),
|
|
1130
2102
|
props.keywords && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("meta", { name: "keywords", content: props.keywords.join(", ") }),
|
|
@@ -1173,7 +2145,6 @@ var SEO = (props) => {
|
|
|
1173
2145
|
};
|
|
1174
2146
|
|
|
1175
2147
|
// src/components/Breadcrumb.tsx
|
|
1176
|
-
var import_react_helmet_async3 = require("react-helmet-async");
|
|
1177
2148
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1178
2149
|
var Breadcrumb = ({
|
|
1179
2150
|
items,
|
|
@@ -1192,7 +2163,7 @@ var Breadcrumb = ({
|
|
|
1192
2163
|
}))
|
|
1193
2164
|
};
|
|
1194
2165
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
1195
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2166
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) }),
|
|
1196
2167
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("nav", { className, "aria-label": "Breadcrumb", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ol", { style: { display: "flex", listStyle: "none", padding: 0 }, children: items.map((item, index) => {
|
|
1197
2168
|
const isLast = index === items.length - 1;
|
|
1198
2169
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("li", { style: { display: "flex", alignItems: "center" }, children: [
|
|
@@ -1248,7 +2219,6 @@ var SeoProduct = ({ item, ...rest }) => {
|
|
|
1248
2219
|
};
|
|
1249
2220
|
|
|
1250
2221
|
// src/components/SeoFAQ.tsx
|
|
1251
|
-
var import_react_helmet_async4 = require("react-helmet-async");
|
|
1252
2222
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1253
2223
|
var SeoFAQ = ({ items }) => {
|
|
1254
2224
|
const schema = {
|
|
@@ -1263,11 +2233,10 @@ var SeoFAQ = ({ items }) => {
|
|
|
1263
2233
|
}
|
|
1264
2234
|
}))
|
|
1265
2235
|
};
|
|
1266
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2236
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
|
|
1267
2237
|
};
|
|
1268
2238
|
|
|
1269
2239
|
// src/components/SeoVideo.tsx
|
|
1270
|
-
var import_react_helmet_async5 = require("react-helmet-async");
|
|
1271
2240
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1272
2241
|
var SeoVideo = ({ video }) => {
|
|
1273
2242
|
const schema = {
|
|
@@ -1286,11 +2255,10 @@ var SeoVideo = ({ video }) => {
|
|
|
1286
2255
|
"userInteractionCount": video.interactionStatistic.viewCount
|
|
1287
2256
|
} : void 0
|
|
1288
2257
|
};
|
|
1289
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2258
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
|
|
1290
2259
|
};
|
|
1291
2260
|
|
|
1292
2261
|
// src/components/SeoEvent.tsx
|
|
1293
|
-
var import_react_helmet_async6 = require("react-helmet-async");
|
|
1294
2262
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1295
2263
|
var SeoEvent = ({ event }) => {
|
|
1296
2264
|
const schema = {
|
|
@@ -1327,11 +2295,10 @@ var SeoEvent = ({ event }) => {
|
|
|
1327
2295
|
"url": event.organizer.url
|
|
1328
2296
|
} : void 0
|
|
1329
2297
|
};
|
|
1330
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2298
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
|
|
1331
2299
|
};
|
|
1332
2300
|
|
|
1333
2301
|
// src/components/SeoLocalBusiness.tsx
|
|
1334
|
-
var import_react_helmet_async7 = require("react-helmet-async");
|
|
1335
2302
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1336
2303
|
var SeoLocalBusiness = ({ business }) => {
|
|
1337
2304
|
const schema = {
|
|
@@ -1359,7 +2326,7 @@ var SeoLocalBusiness = ({ business }) => {
|
|
|
1359
2326
|
} : void 0,
|
|
1360
2327
|
"openingHours": business.openingHours
|
|
1361
2328
|
};
|
|
1362
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2329
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
|
|
1363
2330
|
};
|
|
1364
2331
|
|
|
1365
2332
|
// src/components/SeoCategory.tsx
|
|
@@ -1471,7 +2438,6 @@ var SeoAuthor = ({
|
|
|
1471
2438
|
};
|
|
1472
2439
|
|
|
1473
2440
|
// src/components/SeoHowTo.tsx
|
|
1474
|
-
var import_react_helmet_async8 = require("react-helmet-async");
|
|
1475
2441
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1476
2442
|
var SeoHowTo = ({ name, description, image, steps }) => {
|
|
1477
2443
|
const schema = {
|
|
@@ -1498,11 +2464,10 @@ var SeoHowTo = ({ name, description, image, steps }) => {
|
|
|
1498
2464
|
};
|
|
1499
2465
|
})
|
|
1500
2466
|
};
|
|
1501
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2467
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
|
|
1502
2468
|
};
|
|
1503
2469
|
|
|
1504
2470
|
// src/components/SeoReview.tsx
|
|
1505
|
-
var import_react_helmet_async9 = require("react-helmet-async");
|
|
1506
2471
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1507
2472
|
var SeoReview = ({ itemReviewed, review }) => {
|
|
1508
2473
|
const schema = {
|
|
@@ -1526,11 +2491,10 @@ var SeoReview = ({ itemReviewed, review }) => {
|
|
|
1526
2491
|
"worstRating": review.worstRating || 1
|
|
1527
2492
|
}
|
|
1528
2493
|
};
|
|
1529
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2494
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
|
|
1530
2495
|
};
|
|
1531
2496
|
|
|
1532
2497
|
// src/components/SeoCourse.tsx
|
|
1533
|
-
var import_react_helmet_async10 = require("react-helmet-async");
|
|
1534
2498
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1535
2499
|
var SeoCourse = ({ course }) => {
|
|
1536
2500
|
const schema = {
|
|
@@ -1545,11 +2509,10 @@ var SeoCourse = ({ course }) => {
|
|
|
1545
2509
|
},
|
|
1546
2510
|
"image": course.image
|
|
1547
2511
|
};
|
|
1548
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2512
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
|
|
1549
2513
|
};
|
|
1550
2514
|
|
|
1551
2515
|
// src/components/SeoRecipe.tsx
|
|
1552
|
-
var import_react_helmet_async11 = require("react-helmet-async");
|
|
1553
2516
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1554
2517
|
var SeoRecipe = ({ recipe }) => {
|
|
1555
2518
|
const schema = {
|
|
@@ -1577,11 +2540,10 @@ var SeoRecipe = ({ recipe }) => {
|
|
|
1577
2540
|
"image": step.image
|
|
1578
2541
|
}))
|
|
1579
2542
|
};
|
|
1580
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2543
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
|
|
1581
2544
|
};
|
|
1582
2545
|
|
|
1583
2546
|
// src/components/SeoJobPosting.tsx
|
|
1584
|
-
var import_react_helmet_async12 = require("react-helmet-async");
|
|
1585
2547
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1586
2548
|
var SeoJobPosting = ({ job }) => {
|
|
1587
2549
|
const schema = {
|
|
@@ -1624,7 +2586,7 @@ var SeoJobPosting = ({ job }) => {
|
|
|
1624
2586
|
}
|
|
1625
2587
|
} : void 0
|
|
1626
2588
|
};
|
|
1627
|
-
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2589
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
|
|
1628
2590
|
};
|
|
1629
2591
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1630
2592
|
0 && (module.exports = {
|