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