@masters-ws/react-seo 1.4.0 → 1.4.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/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 +2 -8
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
JsonLd,
|
|
3
|
+
__commonJS,
|
|
4
|
+
__toESM,
|
|
3
5
|
cleanSchema,
|
|
4
6
|
generateArticleMetadata,
|
|
5
7
|
generateArticleSchema,
|
|
@@ -29,11 +31,971 @@ import {
|
|
|
29
31
|
generateWebSiteSchema,
|
|
30
32
|
toNextMetadata,
|
|
31
33
|
validateSEO
|
|
32
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-UBBPNSEV.mjs";
|
|
35
|
+
|
|
36
|
+
// node_modules/react-fast-compare/index.js
|
|
37
|
+
var require_react_fast_compare = __commonJS({
|
|
38
|
+
"node_modules/react-fast-compare/index.js"(exports, module) {
|
|
39
|
+
"use strict";
|
|
40
|
+
var hasElementType = typeof Element !== "undefined";
|
|
41
|
+
var hasMap = typeof Map === "function";
|
|
42
|
+
var hasSet = typeof Set === "function";
|
|
43
|
+
var hasArrayBuffer = typeof ArrayBuffer === "function" && !!ArrayBuffer.isView;
|
|
44
|
+
function equal(a, b) {
|
|
45
|
+
if (a === b) return true;
|
|
46
|
+
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
47
|
+
if (a.constructor !== b.constructor) return false;
|
|
48
|
+
var length, i, keys;
|
|
49
|
+
if (Array.isArray(a)) {
|
|
50
|
+
length = a.length;
|
|
51
|
+
if (length != b.length) return false;
|
|
52
|
+
for (i = length; i-- !== 0; )
|
|
53
|
+
if (!equal(a[i], b[i])) return false;
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
var it;
|
|
57
|
+
if (hasMap && a instanceof Map && b instanceof Map) {
|
|
58
|
+
if (a.size !== b.size) return false;
|
|
59
|
+
it = a.entries();
|
|
60
|
+
while (!(i = it.next()).done)
|
|
61
|
+
if (!b.has(i.value[0])) return false;
|
|
62
|
+
it = a.entries();
|
|
63
|
+
while (!(i = it.next()).done)
|
|
64
|
+
if (!equal(i.value[1], b.get(i.value[0]))) return false;
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
if (hasSet && a instanceof Set && b instanceof Set) {
|
|
68
|
+
if (a.size !== b.size) return false;
|
|
69
|
+
it = a.entries();
|
|
70
|
+
while (!(i = it.next()).done)
|
|
71
|
+
if (!b.has(i.value[0])) return false;
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
if (hasArrayBuffer && ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
|
|
75
|
+
length = a.length;
|
|
76
|
+
if (length != b.length) return false;
|
|
77
|
+
for (i = length; i-- !== 0; )
|
|
78
|
+
if (a[i] !== b[i]) return false;
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
|
82
|
+
if (a.valueOf !== Object.prototype.valueOf && typeof a.valueOf === "function" && typeof b.valueOf === "function") return a.valueOf() === b.valueOf();
|
|
83
|
+
if (a.toString !== Object.prototype.toString && typeof a.toString === "function" && typeof b.toString === "function") return a.toString() === b.toString();
|
|
84
|
+
keys = Object.keys(a);
|
|
85
|
+
length = keys.length;
|
|
86
|
+
if (length !== Object.keys(b).length) return false;
|
|
87
|
+
for (i = length; i-- !== 0; )
|
|
88
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
89
|
+
if (hasElementType && a instanceof Element) return false;
|
|
90
|
+
for (i = length; i-- !== 0; ) {
|
|
91
|
+
if ((keys[i] === "_owner" || keys[i] === "__v" || keys[i] === "__o") && a.$$typeof) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (!equal(a[keys[i]], b[keys[i]])) return false;
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
return a !== a && b !== b;
|
|
99
|
+
}
|
|
100
|
+
module.exports = function isEqual(a, b) {
|
|
101
|
+
try {
|
|
102
|
+
return equal(a, b);
|
|
103
|
+
} catch (error) {
|
|
104
|
+
if ((error.message || "").match(/stack|recursion/i)) {
|
|
105
|
+
console.warn("react-fast-compare cannot handle circular refs");
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// node_modules/invariant/invariant.js
|
|
115
|
+
var require_invariant = __commonJS({
|
|
116
|
+
"node_modules/invariant/invariant.js"(exports, module) {
|
|
117
|
+
"use strict";
|
|
118
|
+
var NODE_ENV = process.env.NODE_ENV;
|
|
119
|
+
var invariant2 = function(condition, format, a, b, c, d, e, f) {
|
|
120
|
+
if (NODE_ENV !== "production") {
|
|
121
|
+
if (format === void 0) {
|
|
122
|
+
throw new Error("invariant requires an error message argument");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (!condition) {
|
|
126
|
+
var error;
|
|
127
|
+
if (format === void 0) {
|
|
128
|
+
error = new Error(
|
|
129
|
+
"Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings."
|
|
130
|
+
);
|
|
131
|
+
} else {
|
|
132
|
+
var args = [a, b, c, d, e, f];
|
|
133
|
+
var argIndex = 0;
|
|
134
|
+
error = new Error(
|
|
135
|
+
format.replace(/%s/g, function() {
|
|
136
|
+
return args[argIndex++];
|
|
137
|
+
})
|
|
138
|
+
);
|
|
139
|
+
error.name = "Invariant Violation";
|
|
140
|
+
}
|
|
141
|
+
error.framesToPop = 1;
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
module.exports = invariant2;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// node_modules/shallowequal/index.js
|
|
150
|
+
var require_shallowequal = __commonJS({
|
|
151
|
+
"node_modules/shallowequal/index.js"(exports, module) {
|
|
152
|
+
"use strict";
|
|
153
|
+
module.exports = function shallowEqual2(objA, objB, compare, compareContext) {
|
|
154
|
+
var ret = compare ? compare.call(compareContext, objA, objB) : void 0;
|
|
155
|
+
if (ret !== void 0) {
|
|
156
|
+
return !!ret;
|
|
157
|
+
}
|
|
158
|
+
if (objA === objB) {
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
if (typeof objA !== "object" || !objA || typeof objB !== "object" || !objB) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
var keysA = Object.keys(objA);
|
|
165
|
+
var keysB = Object.keys(objB);
|
|
166
|
+
if (keysA.length !== keysB.length) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
|
|
170
|
+
for (var idx = 0; idx < keysA.length; idx++) {
|
|
171
|
+
var key = keysA[idx];
|
|
172
|
+
if (!bHasOwnProperty(key)) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
var valueA = objA[key];
|
|
176
|
+
var valueB = objB[key];
|
|
177
|
+
ret = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;
|
|
178
|
+
if (ret === false || ret === void 0 && valueA !== valueB) {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return true;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
});
|
|
33
186
|
|
|
34
187
|
// src/components/SEOProvider.tsx
|
|
35
188
|
import { createContext, useContext } from "react";
|
|
36
|
-
|
|
189
|
+
|
|
190
|
+
// node_modules/react-helmet-async/lib/index.esm.js
|
|
191
|
+
var import_react_fast_compare = __toESM(require_react_fast_compare());
|
|
192
|
+
var import_invariant = __toESM(require_invariant());
|
|
193
|
+
var import_shallowequal = __toESM(require_shallowequal());
|
|
194
|
+
import React3, { Component as Component3 } from "react";
|
|
195
|
+
import React2, { Component } from "react";
|
|
196
|
+
import React from "react";
|
|
197
|
+
import { Component as Component2 } from "react";
|
|
198
|
+
var TAG_NAMES = /* @__PURE__ */ ((TAG_NAMES2) => {
|
|
199
|
+
TAG_NAMES2["BASE"] = "base";
|
|
200
|
+
TAG_NAMES2["BODY"] = "body";
|
|
201
|
+
TAG_NAMES2["HEAD"] = "head";
|
|
202
|
+
TAG_NAMES2["HTML"] = "html";
|
|
203
|
+
TAG_NAMES2["LINK"] = "link";
|
|
204
|
+
TAG_NAMES2["META"] = "meta";
|
|
205
|
+
TAG_NAMES2["NOSCRIPT"] = "noscript";
|
|
206
|
+
TAG_NAMES2["SCRIPT"] = "script";
|
|
207
|
+
TAG_NAMES2["STYLE"] = "style";
|
|
208
|
+
TAG_NAMES2["TITLE"] = "title";
|
|
209
|
+
TAG_NAMES2["FRAGMENT"] = "Symbol(react.fragment)";
|
|
210
|
+
return TAG_NAMES2;
|
|
211
|
+
})(TAG_NAMES || {});
|
|
212
|
+
var SEO_PRIORITY_TAGS = {
|
|
213
|
+
link: { rel: ["amphtml", "canonical", "alternate"] },
|
|
214
|
+
script: { type: ["application/ld+json"] },
|
|
215
|
+
meta: {
|
|
216
|
+
charset: "",
|
|
217
|
+
name: ["generator", "robots", "description"],
|
|
218
|
+
property: [
|
|
219
|
+
"og:type",
|
|
220
|
+
"og:title",
|
|
221
|
+
"og:url",
|
|
222
|
+
"og:image",
|
|
223
|
+
"og:image:alt",
|
|
224
|
+
"og:description",
|
|
225
|
+
"twitter:url",
|
|
226
|
+
"twitter:title",
|
|
227
|
+
"twitter:description",
|
|
228
|
+
"twitter:image",
|
|
229
|
+
"twitter:image:alt",
|
|
230
|
+
"twitter:card",
|
|
231
|
+
"twitter:site"
|
|
232
|
+
]
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
var VALID_TAG_NAMES = Object.values(TAG_NAMES);
|
|
236
|
+
var REACT_TAG_MAP = {
|
|
237
|
+
accesskey: "accessKey",
|
|
238
|
+
charset: "charSet",
|
|
239
|
+
class: "className",
|
|
240
|
+
contenteditable: "contentEditable",
|
|
241
|
+
contextmenu: "contextMenu",
|
|
242
|
+
"http-equiv": "httpEquiv",
|
|
243
|
+
itemprop: "itemProp",
|
|
244
|
+
tabindex: "tabIndex"
|
|
245
|
+
};
|
|
246
|
+
var HTML_TAG_MAP = Object.entries(REACT_TAG_MAP).reduce(
|
|
247
|
+
(carry, [key, value]) => {
|
|
248
|
+
carry[value] = key;
|
|
249
|
+
return carry;
|
|
250
|
+
},
|
|
251
|
+
{}
|
|
252
|
+
);
|
|
253
|
+
var HELMET_ATTRIBUTE = "data-rh";
|
|
254
|
+
var HELMET_PROPS = {
|
|
255
|
+
DEFAULT_TITLE: "defaultTitle",
|
|
256
|
+
DEFER: "defer",
|
|
257
|
+
ENCODE_SPECIAL_CHARACTERS: "encodeSpecialCharacters",
|
|
258
|
+
ON_CHANGE_CLIENT_STATE: "onChangeClientState",
|
|
259
|
+
TITLE_TEMPLATE: "titleTemplate",
|
|
260
|
+
PRIORITIZE_SEO_TAGS: "prioritizeSeoTags"
|
|
261
|
+
};
|
|
262
|
+
var getInnermostProperty = (propsList, property) => {
|
|
263
|
+
for (let i = propsList.length - 1; i >= 0; i -= 1) {
|
|
264
|
+
const props = propsList[i];
|
|
265
|
+
if (Object.prototype.hasOwnProperty.call(props, property)) {
|
|
266
|
+
return props[property];
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return null;
|
|
270
|
+
};
|
|
271
|
+
var getTitleFromPropsList = (propsList) => {
|
|
272
|
+
let innermostTitle = getInnermostProperty(
|
|
273
|
+
propsList,
|
|
274
|
+
"title"
|
|
275
|
+
/* TITLE */
|
|
276
|
+
);
|
|
277
|
+
const innermostTemplate = getInnermostProperty(propsList, HELMET_PROPS.TITLE_TEMPLATE);
|
|
278
|
+
if (Array.isArray(innermostTitle)) {
|
|
279
|
+
innermostTitle = innermostTitle.join("");
|
|
280
|
+
}
|
|
281
|
+
if (innermostTemplate && innermostTitle) {
|
|
282
|
+
return innermostTemplate.replace(/%s/g, () => innermostTitle);
|
|
283
|
+
}
|
|
284
|
+
const innermostDefaultTitle = getInnermostProperty(propsList, HELMET_PROPS.DEFAULT_TITLE);
|
|
285
|
+
return innermostTitle || innermostDefaultTitle || void 0;
|
|
286
|
+
};
|
|
287
|
+
var getOnChangeClientState = (propsList) => getInnermostProperty(propsList, HELMET_PROPS.ON_CHANGE_CLIENT_STATE) || (() => {
|
|
288
|
+
});
|
|
289
|
+
var getAttributesFromPropsList = (tagType, propsList) => propsList.filter((props) => typeof props[tagType] !== "undefined").map((props) => props[tagType]).reduce((tagAttrs, current) => ({ ...tagAttrs, ...current }), {});
|
|
290
|
+
var getBaseTagFromPropsList = (primaryAttributes, propsList) => propsList.filter((props) => typeof props[
|
|
291
|
+
"base"
|
|
292
|
+
/* BASE */
|
|
293
|
+
] !== "undefined").map((props) => props[
|
|
294
|
+
"base"
|
|
295
|
+
/* BASE */
|
|
296
|
+
]).reverse().reduce((innermostBaseTag, tag) => {
|
|
297
|
+
if (!innermostBaseTag.length) {
|
|
298
|
+
const keys = Object.keys(tag);
|
|
299
|
+
for (let i = 0; i < keys.length; i += 1) {
|
|
300
|
+
const attributeKey = keys[i];
|
|
301
|
+
const lowerCaseAttributeKey = attributeKey.toLowerCase();
|
|
302
|
+
if (primaryAttributes.indexOf(lowerCaseAttributeKey) !== -1 && tag[lowerCaseAttributeKey]) {
|
|
303
|
+
return innermostBaseTag.concat(tag);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return innermostBaseTag;
|
|
308
|
+
}, []);
|
|
309
|
+
var warn = (msg) => console && typeof console.warn === "function" && console.warn(msg);
|
|
310
|
+
var getTagsFromPropsList = (tagName, primaryAttributes, propsList) => {
|
|
311
|
+
const approvedSeenTags = {};
|
|
312
|
+
return propsList.filter((props) => {
|
|
313
|
+
if (Array.isArray(props[tagName])) {
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
if (typeof props[tagName] !== "undefined") {
|
|
317
|
+
warn(
|
|
318
|
+
`Helmet: ${tagName} should be of type "Array". Instead found type "${typeof props[tagName]}"`
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
return false;
|
|
322
|
+
}).map((props) => props[tagName]).reverse().reduce((approvedTags, instanceTags) => {
|
|
323
|
+
const instanceSeenTags = {};
|
|
324
|
+
instanceTags.filter((tag) => {
|
|
325
|
+
let primaryAttributeKey;
|
|
326
|
+
const keys2 = Object.keys(tag);
|
|
327
|
+
for (let i = 0; i < keys2.length; i += 1) {
|
|
328
|
+
const attributeKey = keys2[i];
|
|
329
|
+
const lowerCaseAttributeKey = attributeKey.toLowerCase();
|
|
330
|
+
if (primaryAttributes.indexOf(lowerCaseAttributeKey) !== -1 && !(primaryAttributeKey === "rel" && tag[primaryAttributeKey].toLowerCase() === "canonical") && !(lowerCaseAttributeKey === "rel" && tag[lowerCaseAttributeKey].toLowerCase() === "stylesheet")) {
|
|
331
|
+
primaryAttributeKey = lowerCaseAttributeKey;
|
|
332
|
+
}
|
|
333
|
+
if (primaryAttributes.indexOf(attributeKey) !== -1 && (attributeKey === "innerHTML" || attributeKey === "cssText" || attributeKey === "itemprop")) {
|
|
334
|
+
primaryAttributeKey = attributeKey;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (!primaryAttributeKey || !tag[primaryAttributeKey]) {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
const value = tag[primaryAttributeKey].toLowerCase();
|
|
341
|
+
if (!approvedSeenTags[primaryAttributeKey]) {
|
|
342
|
+
approvedSeenTags[primaryAttributeKey] = {};
|
|
343
|
+
}
|
|
344
|
+
if (!instanceSeenTags[primaryAttributeKey]) {
|
|
345
|
+
instanceSeenTags[primaryAttributeKey] = {};
|
|
346
|
+
}
|
|
347
|
+
if (!approvedSeenTags[primaryAttributeKey][value]) {
|
|
348
|
+
instanceSeenTags[primaryAttributeKey][value] = true;
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
return false;
|
|
352
|
+
}).reverse().forEach((tag) => approvedTags.push(tag));
|
|
353
|
+
const keys = Object.keys(instanceSeenTags);
|
|
354
|
+
for (let i = 0; i < keys.length; i += 1) {
|
|
355
|
+
const attributeKey = keys[i];
|
|
356
|
+
const tagUnion = {
|
|
357
|
+
...approvedSeenTags[attributeKey],
|
|
358
|
+
...instanceSeenTags[attributeKey]
|
|
359
|
+
};
|
|
360
|
+
approvedSeenTags[attributeKey] = tagUnion;
|
|
361
|
+
}
|
|
362
|
+
return approvedTags;
|
|
363
|
+
}, []).reverse();
|
|
364
|
+
};
|
|
365
|
+
var getAnyTrueFromPropsList = (propsList, checkedTag) => {
|
|
366
|
+
if (Array.isArray(propsList) && propsList.length) {
|
|
367
|
+
for (let index = 0; index < propsList.length; index += 1) {
|
|
368
|
+
const prop = propsList[index];
|
|
369
|
+
if (prop[checkedTag]) {
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return false;
|
|
375
|
+
};
|
|
376
|
+
var reducePropsToState = (propsList) => ({
|
|
377
|
+
baseTag: getBaseTagFromPropsList([
|
|
378
|
+
"href"
|
|
379
|
+
/* HREF */
|
|
380
|
+
], propsList),
|
|
381
|
+
bodyAttributes: getAttributesFromPropsList("bodyAttributes", propsList),
|
|
382
|
+
defer: getInnermostProperty(propsList, HELMET_PROPS.DEFER),
|
|
383
|
+
encode: getInnermostProperty(propsList, HELMET_PROPS.ENCODE_SPECIAL_CHARACTERS),
|
|
384
|
+
htmlAttributes: getAttributesFromPropsList("htmlAttributes", propsList),
|
|
385
|
+
linkTags: getTagsFromPropsList(
|
|
386
|
+
"link",
|
|
387
|
+
[
|
|
388
|
+
"rel",
|
|
389
|
+
"href"
|
|
390
|
+
/* HREF */
|
|
391
|
+
],
|
|
392
|
+
propsList
|
|
393
|
+
),
|
|
394
|
+
metaTags: getTagsFromPropsList(
|
|
395
|
+
"meta",
|
|
396
|
+
[
|
|
397
|
+
"name",
|
|
398
|
+
"charset",
|
|
399
|
+
"http-equiv",
|
|
400
|
+
"property",
|
|
401
|
+
"itemprop"
|
|
402
|
+
/* ITEM_PROP */
|
|
403
|
+
],
|
|
404
|
+
propsList
|
|
405
|
+
),
|
|
406
|
+
noscriptTags: getTagsFromPropsList("noscript", [
|
|
407
|
+
"innerHTML"
|
|
408
|
+
/* INNER_HTML */
|
|
409
|
+
], propsList),
|
|
410
|
+
onChangeClientState: getOnChangeClientState(propsList),
|
|
411
|
+
scriptTags: getTagsFromPropsList(
|
|
412
|
+
"script",
|
|
413
|
+
[
|
|
414
|
+
"src",
|
|
415
|
+
"innerHTML"
|
|
416
|
+
/* INNER_HTML */
|
|
417
|
+
],
|
|
418
|
+
propsList
|
|
419
|
+
),
|
|
420
|
+
styleTags: getTagsFromPropsList("style", [
|
|
421
|
+
"cssText"
|
|
422
|
+
/* CSS_TEXT */
|
|
423
|
+
], propsList),
|
|
424
|
+
title: getTitleFromPropsList(propsList),
|
|
425
|
+
titleAttributes: getAttributesFromPropsList("titleAttributes", propsList),
|
|
426
|
+
prioritizeSeoTags: getAnyTrueFromPropsList(propsList, HELMET_PROPS.PRIORITIZE_SEO_TAGS)
|
|
427
|
+
});
|
|
428
|
+
var flattenArray = (possibleArray) => Array.isArray(possibleArray) ? possibleArray.join("") : possibleArray;
|
|
429
|
+
var checkIfPropsMatch = (props, toMatch) => {
|
|
430
|
+
const keys = Object.keys(props);
|
|
431
|
+
for (let i = 0; i < keys.length; i += 1) {
|
|
432
|
+
if (toMatch[keys[i]] && toMatch[keys[i]].includes(props[keys[i]])) {
|
|
433
|
+
return true;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return false;
|
|
437
|
+
};
|
|
438
|
+
var prioritizer = (elementsList, propsToMatch) => {
|
|
439
|
+
if (Array.isArray(elementsList)) {
|
|
440
|
+
return elementsList.reduce(
|
|
441
|
+
(acc, elementAttrs) => {
|
|
442
|
+
if (checkIfPropsMatch(elementAttrs, propsToMatch)) {
|
|
443
|
+
acc.priority.push(elementAttrs);
|
|
444
|
+
} else {
|
|
445
|
+
acc.default.push(elementAttrs);
|
|
446
|
+
}
|
|
447
|
+
return acc;
|
|
448
|
+
},
|
|
449
|
+
{ priority: [], default: [] }
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
return { default: elementsList, priority: [] };
|
|
453
|
+
};
|
|
454
|
+
var without = (obj, key) => {
|
|
455
|
+
return {
|
|
456
|
+
...obj,
|
|
457
|
+
[key]: void 0
|
|
458
|
+
};
|
|
459
|
+
};
|
|
460
|
+
var SELF_CLOSING_TAGS = [
|
|
461
|
+
"noscript",
|
|
462
|
+
"script",
|
|
463
|
+
"style"
|
|
464
|
+
/* STYLE */
|
|
465
|
+
];
|
|
466
|
+
var encodeSpecialCharacters = (str, encode = true) => {
|
|
467
|
+
if (encode === false) {
|
|
468
|
+
return String(str);
|
|
469
|
+
}
|
|
470
|
+
return String(str).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
471
|
+
};
|
|
472
|
+
var generateElementAttributesAsString = (attributes) => Object.keys(attributes).reduce((str, key) => {
|
|
473
|
+
const attr = typeof attributes[key] !== "undefined" ? `${key}="${attributes[key]}"` : `${key}`;
|
|
474
|
+
return str ? `${str} ${attr}` : attr;
|
|
475
|
+
}, "");
|
|
476
|
+
var generateTitleAsString = (type, title, attributes, encode) => {
|
|
477
|
+
const attributeString = generateElementAttributesAsString(attributes);
|
|
478
|
+
const flattenedTitle = flattenArray(title);
|
|
479
|
+
return attributeString ? `<${type} ${HELMET_ATTRIBUTE}="true" ${attributeString}>${encodeSpecialCharacters(
|
|
480
|
+
flattenedTitle,
|
|
481
|
+
encode
|
|
482
|
+
)}</${type}>` : `<${type} ${HELMET_ATTRIBUTE}="true">${encodeSpecialCharacters(
|
|
483
|
+
flattenedTitle,
|
|
484
|
+
encode
|
|
485
|
+
)}</${type}>`;
|
|
486
|
+
};
|
|
487
|
+
var generateTagsAsString = (type, tags, encode = true) => tags.reduce((str, t) => {
|
|
488
|
+
const tag = t;
|
|
489
|
+
const attributeHtml = Object.keys(tag).filter(
|
|
490
|
+
(attribute) => !(attribute === "innerHTML" || attribute === "cssText")
|
|
491
|
+
).reduce((string, attribute) => {
|
|
492
|
+
const attr = typeof tag[attribute] === "undefined" ? attribute : `${attribute}="${encodeSpecialCharacters(tag[attribute], encode)}"`;
|
|
493
|
+
return string ? `${string} ${attr}` : attr;
|
|
494
|
+
}, "");
|
|
495
|
+
const tagContent = tag.innerHTML || tag.cssText || "";
|
|
496
|
+
const isSelfClosing = SELF_CLOSING_TAGS.indexOf(type) === -1;
|
|
497
|
+
return `${str}<${type} ${HELMET_ATTRIBUTE}="true" ${attributeHtml}${isSelfClosing ? `/>` : `>${tagContent}</${type}>`}`;
|
|
498
|
+
}, "");
|
|
499
|
+
var convertElementAttributesToReactProps = (attributes, initProps = {}) => Object.keys(attributes).reduce((obj, key) => {
|
|
500
|
+
const mapped = REACT_TAG_MAP[key];
|
|
501
|
+
obj[mapped || key] = attributes[key];
|
|
502
|
+
return obj;
|
|
503
|
+
}, initProps);
|
|
504
|
+
var generateTitleAsReactComponent = (_type, title, attributes) => {
|
|
505
|
+
const initProps = {
|
|
506
|
+
key: title,
|
|
507
|
+
[HELMET_ATTRIBUTE]: true
|
|
508
|
+
};
|
|
509
|
+
const props = convertElementAttributesToReactProps(attributes, initProps);
|
|
510
|
+
return [React.createElement("title", props, title)];
|
|
511
|
+
};
|
|
512
|
+
var generateTagsAsReactComponent = (type, tags) => tags.map((tag, i) => {
|
|
513
|
+
const mappedTag = {
|
|
514
|
+
key: i,
|
|
515
|
+
[HELMET_ATTRIBUTE]: true
|
|
516
|
+
};
|
|
517
|
+
Object.keys(tag).forEach((attribute) => {
|
|
518
|
+
const mapped = REACT_TAG_MAP[attribute];
|
|
519
|
+
const mappedAttribute = mapped || attribute;
|
|
520
|
+
if (mappedAttribute === "innerHTML" || mappedAttribute === "cssText") {
|
|
521
|
+
const content = tag.innerHTML || tag.cssText;
|
|
522
|
+
mappedTag.dangerouslySetInnerHTML = { __html: content };
|
|
523
|
+
} else {
|
|
524
|
+
mappedTag[mappedAttribute] = tag[attribute];
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
return React.createElement(type, mappedTag);
|
|
528
|
+
});
|
|
529
|
+
var getMethodsForTag = (type, tags, encode = true) => {
|
|
530
|
+
switch (type) {
|
|
531
|
+
case "title":
|
|
532
|
+
return {
|
|
533
|
+
toComponent: () => generateTitleAsReactComponent(type, tags.title, tags.titleAttributes),
|
|
534
|
+
toString: () => generateTitleAsString(type, tags.title, tags.titleAttributes, encode)
|
|
535
|
+
};
|
|
536
|
+
case "bodyAttributes":
|
|
537
|
+
case "htmlAttributes":
|
|
538
|
+
return {
|
|
539
|
+
toComponent: () => convertElementAttributesToReactProps(tags),
|
|
540
|
+
toString: () => generateElementAttributesAsString(tags)
|
|
541
|
+
};
|
|
542
|
+
default:
|
|
543
|
+
return {
|
|
544
|
+
toComponent: () => generateTagsAsReactComponent(type, tags),
|
|
545
|
+
toString: () => generateTagsAsString(type, tags, encode)
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
var getPriorityMethods = ({ metaTags, linkTags, scriptTags, encode }) => {
|
|
550
|
+
const meta = prioritizer(metaTags, SEO_PRIORITY_TAGS.meta);
|
|
551
|
+
const link = prioritizer(linkTags, SEO_PRIORITY_TAGS.link);
|
|
552
|
+
const script = prioritizer(scriptTags, SEO_PRIORITY_TAGS.script);
|
|
553
|
+
const priorityMethods = {
|
|
554
|
+
toComponent: () => [
|
|
555
|
+
...generateTagsAsReactComponent("meta", meta.priority),
|
|
556
|
+
...generateTagsAsReactComponent("link", link.priority),
|
|
557
|
+
...generateTagsAsReactComponent("script", script.priority)
|
|
558
|
+
],
|
|
559
|
+
toString: () => (
|
|
560
|
+
// generate all the tags as strings and concatenate them
|
|
561
|
+
`${getMethodsForTag("meta", meta.priority, encode)} ${getMethodsForTag(
|
|
562
|
+
"link",
|
|
563
|
+
link.priority,
|
|
564
|
+
encode
|
|
565
|
+
)} ${getMethodsForTag("script", script.priority, encode)}`
|
|
566
|
+
)
|
|
567
|
+
};
|
|
568
|
+
return {
|
|
569
|
+
priorityMethods,
|
|
570
|
+
metaTags: meta.default,
|
|
571
|
+
linkTags: link.default,
|
|
572
|
+
scriptTags: script.default
|
|
573
|
+
};
|
|
574
|
+
};
|
|
575
|
+
var mapStateOnServer = (props) => {
|
|
576
|
+
const {
|
|
577
|
+
baseTag,
|
|
578
|
+
bodyAttributes,
|
|
579
|
+
encode = true,
|
|
580
|
+
htmlAttributes,
|
|
581
|
+
noscriptTags,
|
|
582
|
+
styleTags,
|
|
583
|
+
title = "",
|
|
584
|
+
titleAttributes,
|
|
585
|
+
prioritizeSeoTags
|
|
586
|
+
} = props;
|
|
587
|
+
let { linkTags, metaTags, scriptTags } = props;
|
|
588
|
+
let priorityMethods = {
|
|
589
|
+
toComponent: () => {
|
|
590
|
+
},
|
|
591
|
+
toString: () => ""
|
|
592
|
+
};
|
|
593
|
+
if (prioritizeSeoTags) {
|
|
594
|
+
({ priorityMethods, linkTags, metaTags, scriptTags } = getPriorityMethods(props));
|
|
595
|
+
}
|
|
596
|
+
return {
|
|
597
|
+
priority: priorityMethods,
|
|
598
|
+
base: getMethodsForTag("base", baseTag, encode),
|
|
599
|
+
bodyAttributes: getMethodsForTag("bodyAttributes", bodyAttributes, encode),
|
|
600
|
+
htmlAttributes: getMethodsForTag("htmlAttributes", htmlAttributes, encode),
|
|
601
|
+
link: getMethodsForTag("link", linkTags, encode),
|
|
602
|
+
meta: getMethodsForTag("meta", metaTags, encode),
|
|
603
|
+
noscript: getMethodsForTag("noscript", noscriptTags, encode),
|
|
604
|
+
script: getMethodsForTag("script", scriptTags, encode),
|
|
605
|
+
style: getMethodsForTag("style", styleTags, encode),
|
|
606
|
+
title: getMethodsForTag("title", { title, titleAttributes }, encode)
|
|
607
|
+
};
|
|
608
|
+
};
|
|
609
|
+
var server_default = mapStateOnServer;
|
|
610
|
+
var instances = [];
|
|
611
|
+
var isDocument = !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
612
|
+
var HelmetData = class {
|
|
613
|
+
instances = [];
|
|
614
|
+
canUseDOM = isDocument;
|
|
615
|
+
context;
|
|
616
|
+
value = {
|
|
617
|
+
setHelmet: (serverState) => {
|
|
618
|
+
this.context.helmet = serverState;
|
|
619
|
+
},
|
|
620
|
+
helmetInstances: {
|
|
621
|
+
get: () => this.canUseDOM ? instances : this.instances,
|
|
622
|
+
add: (instance) => {
|
|
623
|
+
(this.canUseDOM ? instances : this.instances).push(instance);
|
|
624
|
+
},
|
|
625
|
+
remove: (instance) => {
|
|
626
|
+
const index = (this.canUseDOM ? instances : this.instances).indexOf(instance);
|
|
627
|
+
(this.canUseDOM ? instances : this.instances).splice(index, 1);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
constructor(context, canUseDOM) {
|
|
632
|
+
this.context = context;
|
|
633
|
+
this.canUseDOM = canUseDOM || false;
|
|
634
|
+
if (!canUseDOM) {
|
|
635
|
+
context.helmet = server_default({
|
|
636
|
+
baseTag: [],
|
|
637
|
+
bodyAttributes: {},
|
|
638
|
+
encodeSpecialCharacters: true,
|
|
639
|
+
htmlAttributes: {},
|
|
640
|
+
linkTags: [],
|
|
641
|
+
metaTags: [],
|
|
642
|
+
noscriptTags: [],
|
|
643
|
+
scriptTags: [],
|
|
644
|
+
styleTags: [],
|
|
645
|
+
title: "",
|
|
646
|
+
titleAttributes: {}
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
var defaultValue = {};
|
|
652
|
+
var Context = React2.createContext(defaultValue);
|
|
653
|
+
var HelmetProvider = class _HelmetProvider extends Component {
|
|
654
|
+
static canUseDOM = isDocument;
|
|
655
|
+
helmetData;
|
|
656
|
+
constructor(props) {
|
|
657
|
+
super(props);
|
|
658
|
+
this.helmetData = new HelmetData(this.props.context || {}, _HelmetProvider.canUseDOM);
|
|
659
|
+
}
|
|
660
|
+
render() {
|
|
661
|
+
return /* @__PURE__ */ React2.createElement(Context.Provider, { value: this.helmetData.value }, this.props.children);
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
var updateTags = (type, tags) => {
|
|
665
|
+
const headElement = document.head || document.querySelector(
|
|
666
|
+
"head"
|
|
667
|
+
/* HEAD */
|
|
668
|
+
);
|
|
669
|
+
const tagNodes = headElement.querySelectorAll(`${type}[${HELMET_ATTRIBUTE}]`);
|
|
670
|
+
const oldTags = [].slice.call(tagNodes);
|
|
671
|
+
const newTags = [];
|
|
672
|
+
let indexToDelete;
|
|
673
|
+
if (tags && tags.length) {
|
|
674
|
+
tags.forEach((tag) => {
|
|
675
|
+
const newElement = document.createElement(type);
|
|
676
|
+
for (const attribute in tag) {
|
|
677
|
+
if (Object.prototype.hasOwnProperty.call(tag, attribute)) {
|
|
678
|
+
if (attribute === "innerHTML") {
|
|
679
|
+
newElement.innerHTML = tag.innerHTML;
|
|
680
|
+
} else if (attribute === "cssText") {
|
|
681
|
+
if (newElement.styleSheet) {
|
|
682
|
+
newElement.styleSheet.cssText = tag.cssText;
|
|
683
|
+
} else {
|
|
684
|
+
newElement.appendChild(document.createTextNode(tag.cssText));
|
|
685
|
+
}
|
|
686
|
+
} else {
|
|
687
|
+
const attr = attribute;
|
|
688
|
+
const value = typeof tag[attr] === "undefined" ? "" : tag[attr];
|
|
689
|
+
newElement.setAttribute(attribute, value);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
newElement.setAttribute(HELMET_ATTRIBUTE, "true");
|
|
694
|
+
if (oldTags.some((existingTag, index) => {
|
|
695
|
+
indexToDelete = index;
|
|
696
|
+
return newElement.isEqualNode(existingTag);
|
|
697
|
+
})) {
|
|
698
|
+
oldTags.splice(indexToDelete, 1);
|
|
699
|
+
} else {
|
|
700
|
+
newTags.push(newElement);
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
oldTags.forEach((tag) => tag.parentNode?.removeChild(tag));
|
|
705
|
+
newTags.forEach((tag) => headElement.appendChild(tag));
|
|
706
|
+
return {
|
|
707
|
+
oldTags,
|
|
708
|
+
newTags
|
|
709
|
+
};
|
|
710
|
+
};
|
|
711
|
+
var updateAttributes = (tagName, attributes) => {
|
|
712
|
+
const elementTag = document.getElementsByTagName(tagName)[0];
|
|
713
|
+
if (!elementTag) {
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
const helmetAttributeString = elementTag.getAttribute(HELMET_ATTRIBUTE);
|
|
717
|
+
const helmetAttributes = helmetAttributeString ? helmetAttributeString.split(",") : [];
|
|
718
|
+
const attributesToRemove = [...helmetAttributes];
|
|
719
|
+
const attributeKeys = Object.keys(attributes);
|
|
720
|
+
for (const attribute of attributeKeys) {
|
|
721
|
+
const value = attributes[attribute] || "";
|
|
722
|
+
if (elementTag.getAttribute(attribute) !== value) {
|
|
723
|
+
elementTag.setAttribute(attribute, value);
|
|
724
|
+
}
|
|
725
|
+
if (helmetAttributes.indexOf(attribute) === -1) {
|
|
726
|
+
helmetAttributes.push(attribute);
|
|
727
|
+
}
|
|
728
|
+
const indexToSave = attributesToRemove.indexOf(attribute);
|
|
729
|
+
if (indexToSave !== -1) {
|
|
730
|
+
attributesToRemove.splice(indexToSave, 1);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
for (let i = attributesToRemove.length - 1; i >= 0; i -= 1) {
|
|
734
|
+
elementTag.removeAttribute(attributesToRemove[i]);
|
|
735
|
+
}
|
|
736
|
+
if (helmetAttributes.length === attributesToRemove.length) {
|
|
737
|
+
elementTag.removeAttribute(HELMET_ATTRIBUTE);
|
|
738
|
+
} else if (elementTag.getAttribute(HELMET_ATTRIBUTE) !== attributeKeys.join(",")) {
|
|
739
|
+
elementTag.setAttribute(HELMET_ATTRIBUTE, attributeKeys.join(","));
|
|
740
|
+
}
|
|
741
|
+
};
|
|
742
|
+
var updateTitle = (title, attributes) => {
|
|
743
|
+
if (typeof title !== "undefined" && document.title !== title) {
|
|
744
|
+
document.title = flattenArray(title);
|
|
745
|
+
}
|
|
746
|
+
updateAttributes("title", attributes);
|
|
747
|
+
};
|
|
748
|
+
var commitTagChanges = (newState, cb) => {
|
|
749
|
+
const {
|
|
750
|
+
baseTag,
|
|
751
|
+
bodyAttributes,
|
|
752
|
+
htmlAttributes,
|
|
753
|
+
linkTags,
|
|
754
|
+
metaTags,
|
|
755
|
+
noscriptTags,
|
|
756
|
+
onChangeClientState,
|
|
757
|
+
scriptTags,
|
|
758
|
+
styleTags,
|
|
759
|
+
title,
|
|
760
|
+
titleAttributes
|
|
761
|
+
} = newState;
|
|
762
|
+
updateAttributes("body", bodyAttributes);
|
|
763
|
+
updateAttributes("html", htmlAttributes);
|
|
764
|
+
updateTitle(title, titleAttributes);
|
|
765
|
+
const tagUpdates = {
|
|
766
|
+
baseTag: updateTags("base", baseTag),
|
|
767
|
+
linkTags: updateTags("link", linkTags),
|
|
768
|
+
metaTags: updateTags("meta", metaTags),
|
|
769
|
+
noscriptTags: updateTags("noscript", noscriptTags),
|
|
770
|
+
scriptTags: updateTags("script", scriptTags),
|
|
771
|
+
styleTags: updateTags("style", styleTags)
|
|
772
|
+
};
|
|
773
|
+
const addedTags = {};
|
|
774
|
+
const removedTags = {};
|
|
775
|
+
Object.keys(tagUpdates).forEach((tagType) => {
|
|
776
|
+
const { newTags, oldTags } = tagUpdates[tagType];
|
|
777
|
+
if (newTags.length) {
|
|
778
|
+
addedTags[tagType] = newTags;
|
|
779
|
+
}
|
|
780
|
+
if (oldTags.length) {
|
|
781
|
+
removedTags[tagType] = tagUpdates[tagType].oldTags;
|
|
782
|
+
}
|
|
783
|
+
});
|
|
784
|
+
if (cb) {
|
|
785
|
+
cb();
|
|
786
|
+
}
|
|
787
|
+
onChangeClientState(newState, addedTags, removedTags);
|
|
788
|
+
};
|
|
789
|
+
var _helmetCallback = null;
|
|
790
|
+
var handleStateChangeOnClient = (newState) => {
|
|
791
|
+
if (_helmetCallback) {
|
|
792
|
+
cancelAnimationFrame(_helmetCallback);
|
|
793
|
+
}
|
|
794
|
+
if (newState.defer) {
|
|
795
|
+
_helmetCallback = requestAnimationFrame(() => {
|
|
796
|
+
commitTagChanges(newState, () => {
|
|
797
|
+
_helmetCallback = null;
|
|
798
|
+
});
|
|
799
|
+
});
|
|
800
|
+
} else {
|
|
801
|
+
commitTagChanges(newState);
|
|
802
|
+
_helmetCallback = null;
|
|
803
|
+
}
|
|
804
|
+
};
|
|
805
|
+
var client_default = handleStateChangeOnClient;
|
|
806
|
+
var HelmetDispatcher = class extends Component2 {
|
|
807
|
+
rendered = false;
|
|
808
|
+
shouldComponentUpdate(nextProps) {
|
|
809
|
+
return !(0, import_shallowequal.default)(nextProps, this.props);
|
|
810
|
+
}
|
|
811
|
+
componentDidUpdate() {
|
|
812
|
+
this.emitChange();
|
|
813
|
+
}
|
|
814
|
+
componentWillUnmount() {
|
|
815
|
+
const { helmetInstances } = this.props.context;
|
|
816
|
+
helmetInstances.remove(this);
|
|
817
|
+
this.emitChange();
|
|
818
|
+
}
|
|
819
|
+
emitChange() {
|
|
820
|
+
const { helmetInstances, setHelmet } = this.props.context;
|
|
821
|
+
let serverState = null;
|
|
822
|
+
const state = reducePropsToState(
|
|
823
|
+
helmetInstances.get().map((instance) => {
|
|
824
|
+
const props = { ...instance.props };
|
|
825
|
+
delete props.context;
|
|
826
|
+
return props;
|
|
827
|
+
})
|
|
828
|
+
);
|
|
829
|
+
if (HelmetProvider.canUseDOM) {
|
|
830
|
+
client_default(state);
|
|
831
|
+
} else if (server_default) {
|
|
832
|
+
serverState = server_default(state);
|
|
833
|
+
}
|
|
834
|
+
setHelmet(serverState);
|
|
835
|
+
}
|
|
836
|
+
// componentWillMount will be deprecated
|
|
837
|
+
// for SSR, initialize on first render
|
|
838
|
+
// constructor is also unsafe in StrictMode
|
|
839
|
+
init() {
|
|
840
|
+
if (this.rendered) {
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
this.rendered = true;
|
|
844
|
+
const { helmetInstances } = this.props.context;
|
|
845
|
+
helmetInstances.add(this);
|
|
846
|
+
this.emitChange();
|
|
847
|
+
}
|
|
848
|
+
render() {
|
|
849
|
+
this.init();
|
|
850
|
+
return null;
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
var Helmet = class extends Component3 {
|
|
854
|
+
static defaultProps = {
|
|
855
|
+
defer: true,
|
|
856
|
+
encodeSpecialCharacters: true,
|
|
857
|
+
prioritizeSeoTags: false
|
|
858
|
+
};
|
|
859
|
+
shouldComponentUpdate(nextProps) {
|
|
860
|
+
return !(0, import_react_fast_compare.default)(without(this.props, "helmetData"), without(nextProps, "helmetData"));
|
|
861
|
+
}
|
|
862
|
+
mapNestedChildrenToProps(child, nestedChildren) {
|
|
863
|
+
if (!nestedChildren) {
|
|
864
|
+
return null;
|
|
865
|
+
}
|
|
866
|
+
switch (child.type) {
|
|
867
|
+
case "script":
|
|
868
|
+
case "noscript":
|
|
869
|
+
return {
|
|
870
|
+
innerHTML: nestedChildren
|
|
871
|
+
};
|
|
872
|
+
case "style":
|
|
873
|
+
return {
|
|
874
|
+
cssText: nestedChildren
|
|
875
|
+
};
|
|
876
|
+
default:
|
|
877
|
+
throw new Error(
|
|
878
|
+
`<${child.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`
|
|
879
|
+
);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
flattenArrayTypeChildren(child, arrayTypeChildren, newChildProps, nestedChildren) {
|
|
883
|
+
return {
|
|
884
|
+
...arrayTypeChildren,
|
|
885
|
+
[child.type]: [
|
|
886
|
+
...arrayTypeChildren[child.type] || [],
|
|
887
|
+
{
|
|
888
|
+
...newChildProps,
|
|
889
|
+
...this.mapNestedChildrenToProps(child, nestedChildren)
|
|
890
|
+
}
|
|
891
|
+
]
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
mapObjectTypeChildren(child, newProps, newChildProps, nestedChildren) {
|
|
895
|
+
switch (child.type) {
|
|
896
|
+
case "title":
|
|
897
|
+
return {
|
|
898
|
+
...newProps,
|
|
899
|
+
[child.type]: nestedChildren,
|
|
900
|
+
titleAttributes: { ...newChildProps }
|
|
901
|
+
};
|
|
902
|
+
case "body":
|
|
903
|
+
return {
|
|
904
|
+
...newProps,
|
|
905
|
+
bodyAttributes: { ...newChildProps }
|
|
906
|
+
};
|
|
907
|
+
case "html":
|
|
908
|
+
return {
|
|
909
|
+
...newProps,
|
|
910
|
+
htmlAttributes: { ...newChildProps }
|
|
911
|
+
};
|
|
912
|
+
default:
|
|
913
|
+
return {
|
|
914
|
+
...newProps,
|
|
915
|
+
[child.type]: { ...newChildProps }
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
mapArrayTypeChildrenToProps(arrayTypeChildren, newProps) {
|
|
920
|
+
let newFlattenedProps = { ...newProps };
|
|
921
|
+
Object.keys(arrayTypeChildren).forEach((arrayChildName) => {
|
|
922
|
+
newFlattenedProps = {
|
|
923
|
+
...newFlattenedProps,
|
|
924
|
+
[arrayChildName]: arrayTypeChildren[arrayChildName]
|
|
925
|
+
};
|
|
926
|
+
});
|
|
927
|
+
return newFlattenedProps;
|
|
928
|
+
}
|
|
929
|
+
warnOnInvalidChildren(child, nestedChildren) {
|
|
930
|
+
(0, import_invariant.default)(
|
|
931
|
+
VALID_TAG_NAMES.some((name) => child.type === name),
|
|
932
|
+
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(
|
|
933
|
+
", "
|
|
934
|
+
)} are allowed. Helmet does not support rendering <${child.type}> elements. Refer to our API for more information.`
|
|
935
|
+
);
|
|
936
|
+
(0, import_invariant.default)(
|
|
937
|
+
!nestedChildren || typeof nestedChildren === "string" || Array.isArray(nestedChildren) && !nestedChildren.some((nestedChild) => typeof nestedChild !== "string"),
|
|
938
|
+
`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.`
|
|
939
|
+
);
|
|
940
|
+
return true;
|
|
941
|
+
}
|
|
942
|
+
mapChildrenToProps(children, newProps) {
|
|
943
|
+
let arrayTypeChildren = {};
|
|
944
|
+
React3.Children.forEach(children, (child) => {
|
|
945
|
+
if (!child || !child.props) {
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
const { children: nestedChildren, ...childProps } = child.props;
|
|
949
|
+
const newChildProps = Object.keys(childProps).reduce((obj, key) => {
|
|
950
|
+
obj[HTML_TAG_MAP[key] || key] = childProps[key];
|
|
951
|
+
return obj;
|
|
952
|
+
}, {});
|
|
953
|
+
let { type } = child;
|
|
954
|
+
if (typeof type === "symbol") {
|
|
955
|
+
type = type.toString();
|
|
956
|
+
} else {
|
|
957
|
+
this.warnOnInvalidChildren(child, nestedChildren);
|
|
958
|
+
}
|
|
959
|
+
switch (type) {
|
|
960
|
+
case "Symbol(react.fragment)":
|
|
961
|
+
newProps = this.mapChildrenToProps(nestedChildren, newProps);
|
|
962
|
+
break;
|
|
963
|
+
case "link":
|
|
964
|
+
case "meta":
|
|
965
|
+
case "noscript":
|
|
966
|
+
case "script":
|
|
967
|
+
case "style":
|
|
968
|
+
arrayTypeChildren = this.flattenArrayTypeChildren(
|
|
969
|
+
child,
|
|
970
|
+
arrayTypeChildren,
|
|
971
|
+
newChildProps,
|
|
972
|
+
nestedChildren
|
|
973
|
+
);
|
|
974
|
+
break;
|
|
975
|
+
default:
|
|
976
|
+
newProps = this.mapObjectTypeChildren(child, newProps, newChildProps, nestedChildren);
|
|
977
|
+
break;
|
|
978
|
+
}
|
|
979
|
+
});
|
|
980
|
+
return this.mapArrayTypeChildrenToProps(arrayTypeChildren, newProps);
|
|
981
|
+
}
|
|
982
|
+
render() {
|
|
983
|
+
const { children, ...props } = this.props;
|
|
984
|
+
let newProps = { ...props };
|
|
985
|
+
let { helmetData } = props;
|
|
986
|
+
if (children) {
|
|
987
|
+
newProps = this.mapChildrenToProps(children, newProps);
|
|
988
|
+
}
|
|
989
|
+
if (helmetData && !(helmetData instanceof HelmetData)) {
|
|
990
|
+
const data = helmetData;
|
|
991
|
+
helmetData = new HelmetData(data.context, true);
|
|
992
|
+
delete newProps.helmetData;
|
|
993
|
+
}
|
|
994
|
+
return helmetData ? /* @__PURE__ */ React3.createElement(HelmetDispatcher, { ...newProps, context: helmetData.value }) : /* @__PURE__ */ React3.createElement(Context.Consumer, null, (context) => /* @__PURE__ */ React3.createElement(HelmetDispatcher, { ...newProps, context }));
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
|
|
998
|
+
// src/components/SEOProvider.tsx
|
|
37
999
|
import { jsx } from "react/jsx-runtime";
|
|
38
1000
|
var SEOContext = createContext(void 0);
|
|
39
1001
|
var SEOProvider = ({ config, children, helmetContext }) => {
|
|
@@ -48,7 +1010,6 @@ var useSEOConfig = () => {
|
|
|
48
1010
|
};
|
|
49
1011
|
|
|
50
1012
|
// src/components/SEO.tsx
|
|
51
|
-
import { Helmet } from "react-helmet-async";
|
|
52
1013
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
53
1014
|
var SEO = (props) => {
|
|
54
1015
|
const config = useSEOConfig();
|
|
@@ -177,7 +1138,6 @@ var SEO = (props) => {
|
|
|
177
1138
|
};
|
|
178
1139
|
|
|
179
1140
|
// src/components/Breadcrumb.tsx
|
|
180
|
-
import { Helmet as Helmet2 } from "react-helmet-async";
|
|
181
1141
|
import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
182
1142
|
var Breadcrumb = ({
|
|
183
1143
|
items,
|
|
@@ -196,7 +1156,7 @@ var Breadcrumb = ({
|
|
|
196
1156
|
}))
|
|
197
1157
|
};
|
|
198
1158
|
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
199
|
-
/* @__PURE__ */ jsx3(
|
|
1159
|
+
/* @__PURE__ */ jsx3(Helmet, { children: /* @__PURE__ */ jsx3("script", { type: "application/ld+json", children: JSON.stringify(schema) }) }),
|
|
200
1160
|
/* @__PURE__ */ jsx3("nav", { className, "aria-label": "Breadcrumb", children: /* @__PURE__ */ jsx3("ol", { style: { display: "flex", listStyle: "none", padding: 0 }, children: items.map((item, index) => {
|
|
201
1161
|
const isLast = index === items.length - 1;
|
|
202
1162
|
return /* @__PURE__ */ jsxs2("li", { style: { display: "flex", alignItems: "center" }, children: [
|
|
@@ -252,7 +1212,6 @@ var SeoProduct = ({ item, ...rest }) => {
|
|
|
252
1212
|
};
|
|
253
1213
|
|
|
254
1214
|
// src/components/SeoFAQ.tsx
|
|
255
|
-
import { Helmet as Helmet3 } from "react-helmet-async";
|
|
256
1215
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
257
1216
|
var SeoFAQ = ({ items }) => {
|
|
258
1217
|
const schema = {
|
|
@@ -267,11 +1226,10 @@ var SeoFAQ = ({ items }) => {
|
|
|
267
1226
|
}
|
|
268
1227
|
}))
|
|
269
1228
|
};
|
|
270
|
-
return /* @__PURE__ */ jsx6(
|
|
1229
|
+
return /* @__PURE__ */ jsx6(Helmet, { children: /* @__PURE__ */ jsx6("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
|
|
271
1230
|
};
|
|
272
1231
|
|
|
273
1232
|
// src/components/SeoVideo.tsx
|
|
274
|
-
import { Helmet as Helmet4 } from "react-helmet-async";
|
|
275
1233
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
276
1234
|
var SeoVideo = ({ video }) => {
|
|
277
1235
|
const schema = {
|
|
@@ -290,11 +1248,10 @@ var SeoVideo = ({ video }) => {
|
|
|
290
1248
|
"userInteractionCount": video.interactionStatistic.viewCount
|
|
291
1249
|
} : void 0
|
|
292
1250
|
};
|
|
293
|
-
return /* @__PURE__ */ jsx7(
|
|
1251
|
+
return /* @__PURE__ */ jsx7(Helmet, { children: /* @__PURE__ */ jsx7("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
|
|
294
1252
|
};
|
|
295
1253
|
|
|
296
1254
|
// src/components/SeoEvent.tsx
|
|
297
|
-
import { Helmet as Helmet5 } from "react-helmet-async";
|
|
298
1255
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
299
1256
|
var SeoEvent = ({ event }) => {
|
|
300
1257
|
const schema = {
|
|
@@ -331,11 +1288,10 @@ var SeoEvent = ({ event }) => {
|
|
|
331
1288
|
"url": event.organizer.url
|
|
332
1289
|
} : void 0
|
|
333
1290
|
};
|
|
334
|
-
return /* @__PURE__ */ jsx8(
|
|
1291
|
+
return /* @__PURE__ */ jsx8(Helmet, { children: /* @__PURE__ */ jsx8("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
|
|
335
1292
|
};
|
|
336
1293
|
|
|
337
1294
|
// src/components/SeoLocalBusiness.tsx
|
|
338
|
-
import { Helmet as Helmet6 } from "react-helmet-async";
|
|
339
1295
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
340
1296
|
var SeoLocalBusiness = ({ business }) => {
|
|
341
1297
|
const schema = {
|
|
@@ -363,7 +1319,7 @@ var SeoLocalBusiness = ({ business }) => {
|
|
|
363
1319
|
} : void 0,
|
|
364
1320
|
"openingHours": business.openingHours
|
|
365
1321
|
};
|
|
366
|
-
return /* @__PURE__ */ jsx9(
|
|
1322
|
+
return /* @__PURE__ */ jsx9(Helmet, { children: /* @__PURE__ */ jsx9("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
|
|
367
1323
|
};
|
|
368
1324
|
|
|
369
1325
|
// src/components/SeoCategory.tsx
|
|
@@ -475,7 +1431,6 @@ var SeoAuthor = ({
|
|
|
475
1431
|
};
|
|
476
1432
|
|
|
477
1433
|
// src/components/SeoHowTo.tsx
|
|
478
|
-
import { Helmet as Helmet7 } from "react-helmet-async";
|
|
479
1434
|
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
480
1435
|
var SeoHowTo = ({ name, description, image, steps }) => {
|
|
481
1436
|
const schema = {
|
|
@@ -502,11 +1457,10 @@ var SeoHowTo = ({ name, description, image, steps }) => {
|
|
|
502
1457
|
};
|
|
503
1458
|
})
|
|
504
1459
|
};
|
|
505
|
-
return /* @__PURE__ */ jsx13(
|
|
1460
|
+
return /* @__PURE__ */ jsx13(Helmet, { children: /* @__PURE__ */ jsx13("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
|
|
506
1461
|
};
|
|
507
1462
|
|
|
508
1463
|
// src/components/SeoReview.tsx
|
|
509
|
-
import { Helmet as Helmet8 } from "react-helmet-async";
|
|
510
1464
|
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
511
1465
|
var SeoReview = ({ itemReviewed, review }) => {
|
|
512
1466
|
const schema = {
|
|
@@ -530,11 +1484,10 @@ var SeoReview = ({ itemReviewed, review }) => {
|
|
|
530
1484
|
"worstRating": review.worstRating || 1
|
|
531
1485
|
}
|
|
532
1486
|
};
|
|
533
|
-
return /* @__PURE__ */ jsx14(
|
|
1487
|
+
return /* @__PURE__ */ jsx14(Helmet, { children: /* @__PURE__ */ jsx14("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
|
|
534
1488
|
};
|
|
535
1489
|
|
|
536
1490
|
// src/components/SeoCourse.tsx
|
|
537
|
-
import { Helmet as Helmet9 } from "react-helmet-async";
|
|
538
1491
|
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
539
1492
|
var SeoCourse = ({ course }) => {
|
|
540
1493
|
const schema = {
|
|
@@ -549,11 +1502,10 @@ var SeoCourse = ({ course }) => {
|
|
|
549
1502
|
},
|
|
550
1503
|
"image": course.image
|
|
551
1504
|
};
|
|
552
|
-
return /* @__PURE__ */ jsx15(
|
|
1505
|
+
return /* @__PURE__ */ jsx15(Helmet, { children: /* @__PURE__ */ jsx15("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
|
|
553
1506
|
};
|
|
554
1507
|
|
|
555
1508
|
// src/components/SeoRecipe.tsx
|
|
556
|
-
import { Helmet as Helmet10 } from "react-helmet-async";
|
|
557
1509
|
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
558
1510
|
var SeoRecipe = ({ recipe }) => {
|
|
559
1511
|
const schema = {
|
|
@@ -581,11 +1533,10 @@ var SeoRecipe = ({ recipe }) => {
|
|
|
581
1533
|
"image": step.image
|
|
582
1534
|
}))
|
|
583
1535
|
};
|
|
584
|
-
return /* @__PURE__ */ jsx16(
|
|
1536
|
+
return /* @__PURE__ */ jsx16(Helmet, { children: /* @__PURE__ */ jsx16("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
|
|
585
1537
|
};
|
|
586
1538
|
|
|
587
1539
|
// src/components/SeoJobPosting.tsx
|
|
588
|
-
import { Helmet as Helmet11 } from "react-helmet-async";
|
|
589
1540
|
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
590
1541
|
var SeoJobPosting = ({ job }) => {
|
|
591
1542
|
const schema = {
|
|
@@ -628,7 +1579,7 @@ var SeoJobPosting = ({ job }) => {
|
|
|
628
1579
|
}
|
|
629
1580
|
} : void 0
|
|
630
1581
|
};
|
|
631
|
-
return /* @__PURE__ */ jsx17(
|
|
1582
|
+
return /* @__PURE__ */ jsx17(Helmet, { children: /* @__PURE__ */ jsx17("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
|
|
632
1583
|
};
|
|
633
1584
|
export {
|
|
634
1585
|
Breadcrumb,
|