@masters-ws/react-seo 1.0.0 → 1.2.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/dist/index.js CHANGED
@@ -1,13 +1,8 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJS = (cb, mod) => function __require() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
11
6
  var __export = (target, all) => {
12
7
  for (var name in all)
13
8
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -20,167 +15,8 @@ var __copyProps = (to, from, except, desc) => {
20
15
  }
21
16
  return to;
22
17
  };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
- // If the importer is in node compatibility mode or this is not an ESM
25
- // file that has been converted to a CommonJS file using a Babel-
26
- // compatible transform (i.e. "__esModule" has not been set), then set
27
- // "default" to the CommonJS "module.exports" for node compatibility.
28
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
- mod
30
- ));
31
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
19
 
33
- // node_modules/react-fast-compare/index.js
34
- var require_react_fast_compare = __commonJS({
35
- "node_modules/react-fast-compare/index.js"(exports2, module2) {
36
- "use strict";
37
- var hasElementType = typeof Element !== "undefined";
38
- var hasMap = typeof Map === "function";
39
- var hasSet = typeof Set === "function";
40
- var hasArrayBuffer = typeof ArrayBuffer === "function" && !!ArrayBuffer.isView;
41
- function equal(a, b) {
42
- if (a === b) return true;
43
- if (a && b && typeof a == "object" && typeof b == "object") {
44
- if (a.constructor !== b.constructor) return false;
45
- var length, i, keys;
46
- if (Array.isArray(a)) {
47
- length = a.length;
48
- if (length != b.length) return false;
49
- for (i = length; i-- !== 0; )
50
- if (!equal(a[i], b[i])) return false;
51
- return true;
52
- }
53
- var it;
54
- if (hasMap && a instanceof Map && b instanceof Map) {
55
- if (a.size !== b.size) return false;
56
- it = a.entries();
57
- while (!(i = it.next()).done)
58
- if (!b.has(i.value[0])) return false;
59
- it = a.entries();
60
- while (!(i = it.next()).done)
61
- if (!equal(i.value[1], b.get(i.value[0]))) return false;
62
- return true;
63
- }
64
- if (hasSet && a instanceof Set && b instanceof Set) {
65
- if (a.size !== b.size) return false;
66
- it = a.entries();
67
- while (!(i = it.next()).done)
68
- if (!b.has(i.value[0])) return false;
69
- return true;
70
- }
71
- if (hasArrayBuffer && ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
72
- length = a.length;
73
- if (length != b.length) return false;
74
- for (i = length; i-- !== 0; )
75
- if (a[i] !== b[i]) return false;
76
- return true;
77
- }
78
- if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
79
- if (a.valueOf !== Object.prototype.valueOf && typeof a.valueOf === "function" && typeof b.valueOf === "function") return a.valueOf() === b.valueOf();
80
- if (a.toString !== Object.prototype.toString && typeof a.toString === "function" && typeof b.toString === "function") return a.toString() === b.toString();
81
- keys = Object.keys(a);
82
- length = keys.length;
83
- if (length !== Object.keys(b).length) return false;
84
- for (i = length; i-- !== 0; )
85
- if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
86
- if (hasElementType && a instanceof Element) return false;
87
- for (i = length; i-- !== 0; ) {
88
- if ((keys[i] === "_owner" || keys[i] === "__v" || keys[i] === "__o") && a.$$typeof) {
89
- continue;
90
- }
91
- if (!equal(a[keys[i]], b[keys[i]])) return false;
92
- }
93
- return true;
94
- }
95
- return a !== a && b !== b;
96
- }
97
- module2.exports = function isEqual(a, b) {
98
- try {
99
- return equal(a, b);
100
- } catch (error) {
101
- if ((error.message || "").match(/stack|recursion/i)) {
102
- console.warn("react-fast-compare cannot handle circular refs");
103
- return false;
104
- }
105
- throw error;
106
- }
107
- };
108
- }
109
- });
110
-
111
- // node_modules/invariant/invariant.js
112
- var require_invariant = __commonJS({
113
- "node_modules/invariant/invariant.js"(exports2, module2) {
114
- "use strict";
115
- var NODE_ENV = process.env.NODE_ENV;
116
- var invariant2 = function(condition, format, a, b, c, d, e, f) {
117
- if (NODE_ENV !== "production") {
118
- if (format === void 0) {
119
- throw new Error("invariant requires an error message argument");
120
- }
121
- }
122
- if (!condition) {
123
- var error;
124
- if (format === void 0) {
125
- error = new Error(
126
- "Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings."
127
- );
128
- } else {
129
- var args = [a, b, c, d, e, f];
130
- var argIndex = 0;
131
- error = new Error(
132
- format.replace(/%s/g, function() {
133
- return args[argIndex++];
134
- })
135
- );
136
- error.name = "Invariant Violation";
137
- }
138
- error.framesToPop = 1;
139
- throw error;
140
- }
141
- };
142
- module2.exports = invariant2;
143
- }
144
- });
145
-
146
- // node_modules/shallowequal/index.js
147
- var require_shallowequal = __commonJS({
148
- "node_modules/shallowequal/index.js"(exports2, module2) {
149
- "use strict";
150
- module2.exports = function shallowEqual2(objA, objB, compare, compareContext) {
151
- var ret = compare ? compare.call(compareContext, objA, objB) : void 0;
152
- if (ret !== void 0) {
153
- return !!ret;
154
- }
155
- if (objA === objB) {
156
- return true;
157
- }
158
- if (typeof objA !== "object" || !objA || typeof objB !== "object" || !objB) {
159
- return false;
160
- }
161
- var keysA = Object.keys(objA);
162
- var keysB = Object.keys(objB);
163
- if (keysA.length !== keysB.length) {
164
- return false;
165
- }
166
- var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
167
- for (var idx = 0; idx < keysA.length; idx++) {
168
- var key = keysA[idx];
169
- if (!bHasOwnProperty(key)) {
170
- return false;
171
- }
172
- var valueA = objA[key];
173
- var valueB = objB[key];
174
- ret = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;
175
- if (ret === false || ret === void 0 && valueA !== valueB) {
176
- return false;
177
- }
178
- }
179
- return true;
180
- };
181
- }
182
- });
183
-
184
20
  // src/index.ts
185
21
  var index_exports = {};
186
22
  __export(index_exports, {
@@ -201,830 +37,375 @@ __export(index_exports, {
201
37
  SeoReview: () => SeoReview,
202
38
  SeoTag: () => SeoTag,
203
39
  SeoVideo: () => SeoVideo,
40
+ generateArticleSchema: () => generateArticleSchema,
41
+ generateBookSchema: () => generateBookSchema,
42
+ generateBreadcrumbSchema: () => generateBreadcrumbSchema,
43
+ generateEventSchema: () => generateEventSchema,
44
+ generateFAQSchema: () => generateFAQSchema,
45
+ generateLocalBusinessSchema: () => generateLocalBusinessSchema,
46
+ generateMovieSchema: () => generateMovieSchema,
47
+ generateOrganizationSchema: () => generateOrganizationSchema,
48
+ generatePaginatedTitle: () => generatePaginatedTitle,
49
+ generatePaginationLinks: () => generatePaginationLinks,
50
+ generatePodcastEpisodeSchema: () => generatePodcastEpisodeSchema,
51
+ generatePodcastSchema: () => generatePodcastSchema,
52
+ generateProductSchema: () => generateProductSchema,
53
+ generateSoftwareSchema: () => generateSoftwareSchema,
54
+ generateVideoSchema: () => generateVideoSchema,
55
+ generateWebSiteSchema: () => generateWebSiteSchema,
204
56
  toNextMetadata: () => toNextMetadata,
205
57
  useSEOConfig: () => useSEOConfig
206
58
  });
207
59
  module.exports = __toCommonJS(index_exports);
208
60
 
209
- // src/components/SEOProvider.tsx
210
- var import_react5 = require("react");
211
-
212
- // node_modules/react-helmet-async/lib/index.esm.js
213
- var import_react = __toESM(require("react"));
214
- var import_react_fast_compare = __toESM(require_react_fast_compare());
215
- var import_invariant = __toESM(require_invariant());
216
- var import_react2 = __toESM(require("react"));
217
- var import_react3 = __toESM(require("react"));
218
- var import_react4 = require("react");
219
- var import_shallowequal = __toESM(require_shallowequal());
220
- var TAG_NAMES = /* @__PURE__ */ ((TAG_NAMES2) => {
221
- TAG_NAMES2["BASE"] = "base";
222
- TAG_NAMES2["BODY"] = "body";
223
- TAG_NAMES2["HEAD"] = "head";
224
- TAG_NAMES2["HTML"] = "html";
225
- TAG_NAMES2["LINK"] = "link";
226
- TAG_NAMES2["META"] = "meta";
227
- TAG_NAMES2["NOSCRIPT"] = "noscript";
228
- TAG_NAMES2["SCRIPT"] = "script";
229
- TAG_NAMES2["STYLE"] = "style";
230
- TAG_NAMES2["TITLE"] = "title";
231
- TAG_NAMES2["FRAGMENT"] = "Symbol(react.fragment)";
232
- return TAG_NAMES2;
233
- })(TAG_NAMES || {});
234
- var SEO_PRIORITY_TAGS = {
235
- link: { rel: ["amphtml", "canonical", "alternate"] },
236
- script: { type: ["application/ld+json"] },
237
- meta: {
238
- charset: "",
239
- name: ["generator", "robots", "description"],
240
- property: [
241
- "og:type",
242
- "og:title",
243
- "og:url",
244
- "og:image",
245
- "og:image:alt",
246
- "og:description",
247
- "twitter:url",
248
- "twitter:title",
249
- "twitter:description",
250
- "twitter:image",
251
- "twitter:image:alt",
252
- "twitter:card",
253
- "twitter:site"
254
- ]
255
- }
256
- };
257
- var VALID_TAG_NAMES = Object.values(TAG_NAMES);
258
- var REACT_TAG_MAP = {
259
- accesskey: "accessKey",
260
- charset: "charSet",
261
- class: "className",
262
- contenteditable: "contentEditable",
263
- contextmenu: "contextMenu",
264
- "http-equiv": "httpEquiv",
265
- itemprop: "itemProp",
266
- tabindex: "tabIndex"
267
- };
268
- var HTML_TAG_MAP = Object.entries(REACT_TAG_MAP).reduce(
269
- (carry, [key, value]) => {
270
- carry[value] = key;
271
- return carry;
272
- },
273
- {}
274
- );
275
- var HELMET_ATTRIBUTE = "data-rh";
276
- var HELMET_PROPS = {
277
- DEFAULT_TITLE: "defaultTitle",
278
- DEFER: "defer",
279
- ENCODE_SPECIAL_CHARACTERS: "encodeSpecialCharacters",
280
- ON_CHANGE_CLIENT_STATE: "onChangeClientState",
281
- TITLE_TEMPLATE: "titleTemplate",
282
- PRIORITIZE_SEO_TAGS: "prioritizeSeoTags"
283
- };
284
- var getInnermostProperty = (propsList, property) => {
285
- for (let i = propsList.length - 1; i >= 0; i -= 1) {
286
- const props = propsList[i];
287
- if (Object.prototype.hasOwnProperty.call(props, property)) {
288
- return props[property];
289
- }
290
- }
291
- return null;
292
- };
293
- var getTitleFromPropsList = (propsList) => {
294
- let innermostTitle = getInnermostProperty(
295
- propsList,
296
- "title"
297
- /* TITLE */
298
- );
299
- const innermostTemplate = getInnermostProperty(propsList, HELMET_PROPS.TITLE_TEMPLATE);
300
- if (Array.isArray(innermostTitle)) {
301
- innermostTitle = innermostTitle.join("");
302
- }
303
- if (innermostTemplate && innermostTitle) {
304
- return innermostTemplate.replace(/%s/g, () => innermostTitle);
305
- }
306
- const innermostDefaultTitle = getInnermostProperty(propsList, HELMET_PROPS.DEFAULT_TITLE);
307
- return innermostTitle || innermostDefaultTitle || void 0;
308
- };
309
- var getOnChangeClientState = (propsList) => getInnermostProperty(propsList, HELMET_PROPS.ON_CHANGE_CLIENT_STATE) || (() => {
310
- });
311
- var getAttributesFromPropsList = (tagType, propsList) => propsList.filter((props) => typeof props[tagType] !== "undefined").map((props) => props[tagType]).reduce((tagAttrs, current) => ({ ...tagAttrs, ...current }), {});
312
- var getBaseTagFromPropsList = (primaryAttributes, propsList) => propsList.filter((props) => typeof props[
313
- "base"
314
- /* BASE */
315
- ] !== "undefined").map((props) => props[
316
- "base"
317
- /* BASE */
318
- ]).reverse().reduce((innermostBaseTag, tag) => {
319
- if (!innermostBaseTag.length) {
320
- const keys = Object.keys(tag);
321
- for (let i = 0; i < keys.length; i += 1) {
322
- const attributeKey = keys[i];
323
- const lowerCaseAttributeKey = attributeKey.toLowerCase();
324
- if (primaryAttributes.indexOf(lowerCaseAttributeKey) !== -1 && tag[lowerCaseAttributeKey]) {
325
- return innermostBaseTag.concat(tag);
326
- }
327
- }
328
- }
329
- return innermostBaseTag;
330
- }, []);
331
- var warn = (msg) => console && typeof console.warn === "function" && console.warn(msg);
332
- var getTagsFromPropsList = (tagName, primaryAttributes, propsList) => {
333
- const approvedSeenTags = {};
334
- return propsList.filter((props) => {
335
- if (Array.isArray(props[tagName])) {
336
- return true;
337
- }
338
- if (typeof props[tagName] !== "undefined") {
339
- warn(
340
- `Helmet: ${tagName} should be of type "Array". Instead found type "${typeof props[tagName]}"`
341
- );
342
- }
343
- return false;
344
- }).map((props) => props[tagName]).reverse().reduce((approvedTags, instanceTags) => {
345
- const instanceSeenTags = {};
346
- instanceTags.filter((tag) => {
347
- let primaryAttributeKey;
348
- const keys2 = Object.keys(tag);
349
- for (let i = 0; i < keys2.length; i += 1) {
350
- const attributeKey = keys2[i];
351
- const lowerCaseAttributeKey = attributeKey.toLowerCase();
352
- if (primaryAttributes.indexOf(lowerCaseAttributeKey) !== -1 && !(primaryAttributeKey === "rel" && tag[primaryAttributeKey].toLowerCase() === "canonical") && !(lowerCaseAttributeKey === "rel" && tag[lowerCaseAttributeKey].toLowerCase() === "stylesheet")) {
353
- primaryAttributeKey = lowerCaseAttributeKey;
354
- }
355
- if (primaryAttributes.indexOf(attributeKey) !== -1 && (attributeKey === "innerHTML" || attributeKey === "cssText" || attributeKey === "itemprop")) {
356
- primaryAttributeKey = attributeKey;
357
- }
358
- }
359
- if (!primaryAttributeKey || !tag[primaryAttributeKey]) {
360
- return false;
361
- }
362
- const value = tag[primaryAttributeKey].toLowerCase();
363
- if (!approvedSeenTags[primaryAttributeKey]) {
364
- approvedSeenTags[primaryAttributeKey] = {};
365
- }
366
- if (!instanceSeenTags[primaryAttributeKey]) {
367
- instanceSeenTags[primaryAttributeKey] = {};
368
- }
369
- if (!approvedSeenTags[primaryAttributeKey][value]) {
370
- instanceSeenTags[primaryAttributeKey][value] = true;
371
- return true;
372
- }
373
- return false;
374
- }).reverse().forEach((tag) => approvedTags.push(tag));
375
- const keys = Object.keys(instanceSeenTags);
376
- for (let i = 0; i < keys.length; i += 1) {
377
- const attributeKey = keys[i];
378
- const tagUnion = {
379
- ...approvedSeenTags[attributeKey],
380
- ...instanceSeenTags[attributeKey]
381
- };
382
- approvedSeenTags[attributeKey] = tagUnion;
383
- }
384
- return approvedTags;
385
- }, []).reverse();
386
- };
387
- var getAnyTrueFromPropsList = (propsList, checkedTag) => {
388
- if (Array.isArray(propsList) && propsList.length) {
389
- for (let index = 0; index < propsList.length; index += 1) {
390
- const prop = propsList[index];
391
- if (prop[checkedTag]) {
392
- return true;
393
- }
394
- }
395
- }
396
- return false;
397
- };
398
- var reducePropsToState = (propsList) => ({
399
- baseTag: getBaseTagFromPropsList([
400
- "href"
401
- /* HREF */
402
- ], propsList),
403
- bodyAttributes: getAttributesFromPropsList("bodyAttributes", propsList),
404
- defer: getInnermostProperty(propsList, HELMET_PROPS.DEFER),
405
- encode: getInnermostProperty(propsList, HELMET_PROPS.ENCODE_SPECIAL_CHARACTERS),
406
- htmlAttributes: getAttributesFromPropsList("htmlAttributes", propsList),
407
- linkTags: getTagsFromPropsList(
408
- "link",
409
- [
410
- "rel",
411
- "href"
412
- /* HREF */
413
- ],
414
- propsList
415
- ),
416
- metaTags: getTagsFromPropsList(
417
- "meta",
418
- [
419
- "name",
420
- "charset",
421
- "http-equiv",
422
- "property",
423
- "itemprop"
424
- /* ITEM_PROP */
425
- ],
426
- propsList
427
- ),
428
- noscriptTags: getTagsFromPropsList("noscript", [
429
- "innerHTML"
430
- /* INNER_HTML */
431
- ], propsList),
432
- onChangeClientState: getOnChangeClientState(propsList),
433
- scriptTags: getTagsFromPropsList(
434
- "script",
435
- [
436
- "src",
437
- "innerHTML"
438
- /* INNER_HTML */
439
- ],
440
- propsList
441
- ),
442
- styleTags: getTagsFromPropsList("style", [
443
- "cssText"
444
- /* CSS_TEXT */
445
- ], propsList),
446
- title: getTitleFromPropsList(propsList),
447
- titleAttributes: getAttributesFromPropsList("titleAttributes", propsList),
448
- prioritizeSeoTags: getAnyTrueFromPropsList(propsList, HELMET_PROPS.PRIORITIZE_SEO_TAGS)
449
- });
450
- var flattenArray = (possibleArray) => Array.isArray(possibleArray) ? possibleArray.join("") : possibleArray;
451
- var checkIfPropsMatch = (props, toMatch) => {
452
- const keys = Object.keys(props);
453
- for (let i = 0; i < keys.length; i += 1) {
454
- if (toMatch[keys[i]] && toMatch[keys[i]].includes(props[keys[i]])) {
455
- return true;
61
+ // src/core/schemas.ts
62
+ function generateOrganizationSchema(config) {
63
+ return {
64
+ "@context": "https://schema.org",
65
+ "@type": "Organization",
66
+ "name": config.name,
67
+ "url": config.url,
68
+ "logo": config.logo,
69
+ "sameAs": config.socialLinks || []
70
+ };
71
+ }
72
+ function generateWebSiteSchema(config) {
73
+ return {
74
+ "@context": "https://schema.org",
75
+ "@type": "WebSite",
76
+ "name": config.name,
77
+ "url": config.url,
78
+ "potentialAction": {
79
+ "@type": "SearchAction",
80
+ "target": `${config.url}/search?q={search_term_string}`,
81
+ "query-input": "required name=search_term_string"
456
82
  }
457
- }
458
- return false;
459
- };
460
- var prioritizer = (elementsList, propsToMatch) => {
461
- if (Array.isArray(elementsList)) {
462
- return elementsList.reduce(
463
- (acc, elementAttrs) => {
464
- if (checkIfPropsMatch(elementAttrs, propsToMatch)) {
465
- acc.priority.push(elementAttrs);
466
- } else {
467
- acc.default.push(elementAttrs);
468
- }
469
- return acc;
470
- },
471
- { priority: [], default: [] }
472
- );
473
- }
474
- return { default: elementsList, priority: [] };
475
- };
476
- var without = (obj, key) => {
83
+ };
84
+ }
85
+ function generateArticleSchema(data, config) {
86
+ const org = generateOrganizationSchema(config);
477
87
  return {
478
- ...obj,
479
- [key]: void 0
88
+ "@context": "https://schema.org",
89
+ "@type": "NewsArticle",
90
+ "headline": data.title,
91
+ "description": data.description,
92
+ "image": data.image || config.logo,
93
+ "datePublished": data.publishedTime,
94
+ "dateModified": data.modifiedTime || data.publishedTime,
95
+ "mainEntityOfPage": data.url,
96
+ "author": data.author ? {
97
+ "@type": "Person",
98
+ "name": data.author.name,
99
+ "url": data.author.url
100
+ } : org,
101
+ "publisher": org
480
102
  };
481
- };
482
- var SELF_CLOSING_TAGS = [
483
- "noscript",
484
- "script",
485
- "style"
486
- /* STYLE */
487
- ];
488
- var encodeSpecialCharacters = (str, encode = true) => {
489
- if (encode === false) {
490
- return String(str);
491
- }
492
- return String(str).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;");
493
- };
494
- var generateElementAttributesAsString = (attributes) => Object.keys(attributes).reduce((str, key) => {
495
- const attr = typeof attributes[key] !== "undefined" ? `${key}="${attributes[key]}"` : `${key}`;
496
- return str ? `${str} ${attr}` : attr;
497
- }, "");
498
- var generateTitleAsString = (type, title, attributes, encode) => {
499
- const attributeString = generateElementAttributesAsString(attributes);
500
- const flattenedTitle = flattenArray(title);
501
- return attributeString ? `<${type} ${HELMET_ATTRIBUTE}="true" ${attributeString}>${encodeSpecialCharacters(
502
- flattenedTitle,
503
- encode
504
- )}</${type}>` : `<${type} ${HELMET_ATTRIBUTE}="true">${encodeSpecialCharacters(
505
- flattenedTitle,
506
- encode
507
- )}</${type}>`;
508
- };
509
- var generateTagsAsString = (type, tags, encode = true) => tags.reduce((str, t) => {
510
- const tag = t;
511
- const attributeHtml = Object.keys(tag).filter(
512
- (attribute) => !(attribute === "innerHTML" || attribute === "cssText")
513
- ).reduce((string, attribute) => {
514
- const attr = typeof tag[attribute] === "undefined" ? attribute : `${attribute}="${encodeSpecialCharacters(tag[attribute], encode)}"`;
515
- return string ? `${string} ${attr}` : attr;
516
- }, "");
517
- const tagContent = tag.innerHTML || tag.cssText || "";
518
- const isSelfClosing = SELF_CLOSING_TAGS.indexOf(type) === -1;
519
- return `${str}<${type} ${HELMET_ATTRIBUTE}="true" ${attributeHtml}${isSelfClosing ? `/>` : `>${tagContent}</${type}>`}`;
520
- }, "");
521
- var convertElementAttributesToReactProps = (attributes, initProps = {}) => Object.keys(attributes).reduce((obj, key) => {
522
- const mapped = REACT_TAG_MAP[key];
523
- obj[mapped || key] = attributes[key];
524
- return obj;
525
- }, initProps);
526
- var generateTitleAsReactComponent = (_type, title, attributes) => {
527
- const initProps = {
528
- key: title,
529
- [HELMET_ATTRIBUTE]: true
103
+ }
104
+ function generateProductSchema(data) {
105
+ return {
106
+ "@context": "https://schema.org",
107
+ "@type": "Product",
108
+ "name": data.name,
109
+ "description": data.description,
110
+ "image": data.image,
111
+ "sku": data.sku,
112
+ "brand": data.brand ? { "@type": "Brand", "name": data.brand } : void 0,
113
+ "offers": {
114
+ "@type": "Offer",
115
+ "url": data.url,
116
+ "priceCurrency": data.currency || "USD",
117
+ "price": data.price,
118
+ "availability": data.availability || "https://schema.org/InStock"
119
+ },
120
+ "aggregateRating": data.rating ? {
121
+ "@type": "AggregateRating",
122
+ "ratingValue": data.rating,
123
+ "reviewCount": data.reviewCount || 1
124
+ } : void 0
530
125
  };
531
- const props = convertElementAttributesToReactProps(attributes, initProps);
532
- return [import_react3.default.createElement("title", props, title)];
533
- };
534
- var generateTagsAsReactComponent = (type, tags) => tags.map((tag, i) => {
535
- const mappedTag = {
536
- key: i,
537
- [HELMET_ATTRIBUTE]: true
126
+ }
127
+ function generateFAQSchema(questions) {
128
+ return {
129
+ "@context": "https://schema.org",
130
+ "@type": "FAQPage",
131
+ "mainEntity": questions.map((item) => ({
132
+ "@type": "Question",
133
+ "name": item.q,
134
+ "acceptedAnswer": {
135
+ "@type": "Answer",
136
+ "text": item.a
137
+ }
138
+ }))
538
139
  };
539
- Object.keys(tag).forEach((attribute) => {
540
- const mapped = REACT_TAG_MAP[attribute];
541
- const mappedAttribute = mapped || attribute;
542
- if (mappedAttribute === "innerHTML" || mappedAttribute === "cssText") {
543
- const content = tag.innerHTML || tag.cssText;
544
- mappedTag.dangerouslySetInnerHTML = { __html: content };
545
- } else {
546
- mappedTag[mappedAttribute] = tag[attribute];
547
- }
548
- });
549
- return import_react3.default.createElement(type, mappedTag);
550
- });
551
- var getMethodsForTag = (type, tags, encode = true) => {
552
- switch (type) {
553
- case "title":
554
- return {
555
- toComponent: () => generateTitleAsReactComponent(type, tags.title, tags.titleAttributes),
556
- toString: () => generateTitleAsString(type, tags.title, tags.titleAttributes, encode)
557
- };
558
- case "bodyAttributes":
559
- case "htmlAttributes":
560
- return {
561
- toComponent: () => convertElementAttributesToReactProps(tags),
562
- toString: () => generateElementAttributesAsString(tags)
563
- };
564
- default:
565
- return {
566
- toComponent: () => generateTagsAsReactComponent(type, tags),
567
- toString: () => generateTagsAsString(type, tags, encode)
568
- };
569
- }
570
- };
571
- var getPriorityMethods = ({ metaTags, linkTags, scriptTags, encode }) => {
572
- const meta = prioritizer(metaTags, SEO_PRIORITY_TAGS.meta);
573
- const link = prioritizer(linkTags, SEO_PRIORITY_TAGS.link);
574
- const script = prioritizer(scriptTags, SEO_PRIORITY_TAGS.script);
575
- const priorityMethods = {
576
- toComponent: () => [
577
- ...generateTagsAsReactComponent("meta", meta.priority),
578
- ...generateTagsAsReactComponent("link", link.priority),
579
- ...generateTagsAsReactComponent("script", script.priority)
580
- ],
581
- toString: () => (
582
- // generate all the tags as strings and concatenate them
583
- `${getMethodsForTag("meta", meta.priority, encode)} ${getMethodsForTag(
584
- "link",
585
- link.priority,
586
- encode
587
- )} ${getMethodsForTag("script", script.priority, encode)}`
588
- )
140
+ }
141
+ function generateBreadcrumbSchema(items) {
142
+ return {
143
+ "@context": "https://schema.org",
144
+ "@type": "BreadcrumbList",
145
+ "itemListElement": items.map((item, index) => ({
146
+ "@type": "ListItem",
147
+ "position": index + 1,
148
+ "name": item.name,
149
+ "item": item.item
150
+ }))
589
151
  };
152
+ }
153
+ function generateVideoSchema(data) {
590
154
  return {
591
- priorityMethods,
592
- metaTags: meta.default,
593
- linkTags: link.default,
594
- scriptTags: script.default
155
+ "@context": "https://schema.org",
156
+ "@type": "VideoObject",
157
+ "name": data.name,
158
+ "description": data.description,
159
+ "thumbnailUrl": data.thumbnailUrl,
160
+ "uploadDate": data.uploadDate,
161
+ "duration": data.duration,
162
+ "contentUrl": data.contentUrl,
163
+ "embedUrl": data.embedUrl
595
164
  };
596
- };
597
- var mapStateOnServer = (props) => {
598
- const {
599
- baseTag,
600
- bodyAttributes,
601
- encode = true,
602
- htmlAttributes,
603
- noscriptTags,
604
- styleTags,
605
- title = "",
606
- titleAttributes,
607
- prioritizeSeoTags
608
- } = props;
609
- let { linkTags, metaTags, scriptTags } = props;
610
- let priorityMethods = {
611
- toComponent: () => {
165
+ }
166
+ function generateEventSchema(data) {
167
+ const isOnline = data.location && "url" in data.location;
168
+ return {
169
+ "@context": "https://schema.org",
170
+ "@type": "Event",
171
+ "name": data.name,
172
+ "description": data.description,
173
+ "startDate": data.startDate,
174
+ "endDate": data.endDate,
175
+ "eventAttendanceMode": isOnline ? "https://schema.org/OnlineEventAttendanceMode" : "https://schema.org/OfflineEventAttendanceMode",
176
+ "location": isOnline ? {
177
+ "@type": "VirtualLocation",
178
+ "url": data.location.url
179
+ } : data.location ? {
180
+ "@type": "Place",
181
+ "name": data.location.name,
182
+ "address": data.location.address
183
+ } : void 0,
184
+ "image": data.image,
185
+ "offers": data.offers ? {
186
+ "@type": "Offer",
187
+ "price": data.offers.price,
188
+ "priceCurrency": data.offers.currency,
189
+ "url": data.offers.url
190
+ } : void 0
191
+ };
192
+ }
193
+ function generateLocalBusinessSchema(data) {
194
+ return {
195
+ "@context": "https://schema.org",
196
+ "@type": "LocalBusiness",
197
+ "name": data.name,
198
+ "description": data.description,
199
+ "image": data.image,
200
+ "telephone": data.telephone,
201
+ "address": {
202
+ "@type": "PostalAddress",
203
+ "streetAddress": data.address.street,
204
+ "addressLocality": data.address.city,
205
+ "addressRegion": data.address.region,
206
+ "postalCode": data.address.postalCode,
207
+ "addressCountry": data.address.country
612
208
  },
613
- toString: () => ""
209
+ "geo": data.geo ? {
210
+ "@type": "GeoCoordinates",
211
+ "latitude": data.geo.lat,
212
+ "longitude": data.geo.lng
213
+ } : void 0,
214
+ "openingHours": data.openingHours,
215
+ "priceRange": data.priceRange
614
216
  };
615
- if (prioritizeSeoTags) {
616
- ({ priorityMethods, linkTags, metaTags, scriptTags } = getPriorityMethods(props));
617
- }
217
+ }
218
+ function generateSoftwareSchema(data) {
618
219
  return {
619
- priority: priorityMethods,
620
- base: getMethodsForTag("base", baseTag, encode),
621
- bodyAttributes: getMethodsForTag("bodyAttributes", bodyAttributes, encode),
622
- htmlAttributes: getMethodsForTag("htmlAttributes", htmlAttributes, encode),
623
- link: getMethodsForTag("link", linkTags, encode),
624
- meta: getMethodsForTag("meta", metaTags, encode),
625
- noscript: getMethodsForTag("noscript", noscriptTags, encode),
626
- script: getMethodsForTag("script", scriptTags, encode),
627
- style: getMethodsForTag("style", styleTags, encode),
628
- title: getMethodsForTag("title", { title, titleAttributes }, encode)
220
+ "@context": "https://schema.org",
221
+ "@type": "SoftwareApplication",
222
+ "name": data.name,
223
+ "description": data.description,
224
+ "operatingSystem": data.operatingSystem,
225
+ "applicationCategory": data.applicationCategory,
226
+ "offers": data.offers ? {
227
+ "@type": "Offer",
228
+ "price": data.offers.price,
229
+ "priceCurrency": data.offers.currency
230
+ } : void 0,
231
+ "aggregateRating": data.rating ? {
232
+ "@type": "AggregateRating",
233
+ "ratingValue": data.rating,
234
+ "reviewCount": data.reviewCount || 1
235
+ } : void 0,
236
+ "downloadUrl": data.downloadUrl,
237
+ "screenshot": data.screenshot
629
238
  };
630
- };
631
- var server_default = mapStateOnServer;
632
- var instances = [];
633
- var isDocument = !!(typeof window !== "undefined" && window.document && window.document.createElement);
634
- var HelmetData = class {
635
- instances = [];
636
- canUseDOM = isDocument;
637
- context;
638
- value = {
639
- setHelmet: (serverState) => {
640
- this.context.helmet = serverState;
239
+ }
240
+ function generateBookSchema(data) {
241
+ return {
242
+ "@context": "https://schema.org",
243
+ "@type": "Book",
244
+ "name": data.name,
245
+ "author": typeof data.author === "string" ? {
246
+ "@type": "Person",
247
+ "name": data.author
248
+ } : {
249
+ "@type": "Person",
250
+ "name": data.author.name,
251
+ "url": data.author.url
641
252
  },
642
- helmetInstances: {
643
- get: () => this.canUseDOM ? instances : this.instances,
644
- add: (instance) => {
645
- (this.canUseDOM ? instances : this.instances).push(instance);
646
- },
647
- remove: (instance) => {
648
- const index = (this.canUseDOM ? instances : this.instances).indexOf(instance);
649
- (this.canUseDOM ? instances : this.instances).splice(index, 1);
650
- }
651
- }
253
+ "description": data.description,
254
+ "isbn": data.isbn,
255
+ "numberOfPages": data.numberOfPages,
256
+ "publisher": data.publisher ? {
257
+ "@type": "Organization",
258
+ "name": data.publisher
259
+ } : void 0,
260
+ "datePublished": data.datePublished,
261
+ "image": data.image,
262
+ "inLanguage": data.inLanguage,
263
+ "genre": data.genre
652
264
  };
653
- constructor(context, canUseDOM) {
654
- this.context = context;
655
- this.canUseDOM = canUseDOM || false;
656
- if (!canUseDOM) {
657
- context.helmet = server_default({
658
- baseTag: [],
659
- bodyAttributes: {},
660
- encodeSpecialCharacters: true,
661
- htmlAttributes: {},
662
- linkTags: [],
663
- metaTags: [],
664
- noscriptTags: [],
665
- scriptTags: [],
666
- styleTags: [],
667
- title: "",
668
- titleAttributes: {}
669
- });
670
- }
671
- }
672
- };
673
- var defaultValue = {};
674
- var Context = import_react2.default.createContext(defaultValue);
675
- var HelmetProvider = class _HelmetProvider extends import_react2.Component {
676
- static canUseDOM = isDocument;
677
- helmetData;
678
- constructor(props) {
679
- super(props);
680
- this.helmetData = new HelmetData(this.props.context || {}, _HelmetProvider.canUseDOM);
681
- }
682
- render() {
683
- return /* @__PURE__ */ import_react2.default.createElement(Context.Provider, { value: this.helmetData.value }, this.props.children);
684
- }
685
- };
686
- var updateTags = (type, tags) => {
687
- const headElement = document.head || document.querySelector(
688
- "head"
689
- /* HEAD */
690
- );
691
- const tagNodes = headElement.querySelectorAll(`${type}[${HELMET_ATTRIBUTE}]`);
692
- const oldTags = [].slice.call(tagNodes);
693
- const newTags = [];
694
- let indexToDelete;
695
- if (tags && tags.length) {
696
- tags.forEach((tag) => {
697
- const newElement = document.createElement(type);
698
- for (const attribute in tag) {
699
- if (Object.prototype.hasOwnProperty.call(tag, attribute)) {
700
- if (attribute === "innerHTML") {
701
- newElement.innerHTML = tag.innerHTML;
702
- } else if (attribute === "cssText") {
703
- if (newElement.styleSheet) {
704
- newElement.styleSheet.cssText = tag.cssText;
705
- } else {
706
- newElement.appendChild(document.createTextNode(tag.cssText));
707
- }
708
- } else {
709
- const attr = attribute;
710
- const value = typeof tag[attr] === "undefined" ? "" : tag[attr];
711
- newElement.setAttribute(attribute, value);
712
- }
713
- }
714
- }
715
- newElement.setAttribute(HELMET_ATTRIBUTE, "true");
716
- if (oldTags.some((existingTag, index) => {
717
- indexToDelete = index;
718
- return newElement.isEqualNode(existingTag);
719
- })) {
720
- oldTags.splice(indexToDelete, 1);
721
- } else {
722
- newTags.push(newElement);
723
- }
724
- });
725
- }
726
- oldTags.forEach((tag) => tag.parentNode?.removeChild(tag));
727
- newTags.forEach((tag) => headElement.appendChild(tag));
265
+ }
266
+ function generateMovieSchema(data) {
728
267
  return {
729
- oldTags,
730
- newTags
268
+ "@context": "https://schema.org",
269
+ "@type": "Movie",
270
+ "name": data.name,
271
+ "description": data.description,
272
+ "image": data.image,
273
+ "director": data.director ? {
274
+ "@type": "Person",
275
+ "name": data.director
276
+ } : void 0,
277
+ "actor": data.actor?.map((name) => ({
278
+ "@type": "Person",
279
+ "name": name
280
+ })),
281
+ "dateCreated": data.dateCreated,
282
+ "duration": data.duration,
283
+ "genre": data.genre,
284
+ "aggregateRating": data.rating ? {
285
+ "@type": "AggregateRating",
286
+ "ratingValue": data.rating,
287
+ "reviewCount": data.reviewCount || 1
288
+ } : void 0
731
289
  };
732
- };
733
- var updateAttributes = (tagName, attributes) => {
734
- const elementTag = document.getElementsByTagName(tagName)[0];
735
- if (!elementTag) {
736
- return;
737
- }
738
- const helmetAttributeString = elementTag.getAttribute(HELMET_ATTRIBUTE);
739
- const helmetAttributes = helmetAttributeString ? helmetAttributeString.split(",") : [];
740
- const attributesToRemove = [...helmetAttributes];
741
- const attributeKeys = Object.keys(attributes);
742
- for (const attribute of attributeKeys) {
743
- const value = attributes[attribute] || "";
744
- if (elementTag.getAttribute(attribute) !== value) {
745
- elementTag.setAttribute(attribute, value);
746
- }
747
- if (helmetAttributes.indexOf(attribute) === -1) {
748
- helmetAttributes.push(attribute);
749
- }
750
- const indexToSave = attributesToRemove.indexOf(attribute);
751
- if (indexToSave !== -1) {
752
- attributesToRemove.splice(indexToSave, 1);
753
- }
754
- }
755
- for (let i = attributesToRemove.length - 1; i >= 0; i -= 1) {
756
- elementTag.removeAttribute(attributesToRemove[i]);
757
- }
758
- if (helmetAttributes.length === attributesToRemove.length) {
759
- elementTag.removeAttribute(HELMET_ATTRIBUTE);
760
- } else if (elementTag.getAttribute(HELMET_ATTRIBUTE) !== attributeKeys.join(",")) {
761
- elementTag.setAttribute(HELMET_ATTRIBUTE, attributeKeys.join(","));
762
- }
763
- };
764
- var updateTitle = (title, attributes) => {
765
- if (typeof title !== "undefined" && document.title !== title) {
766
- document.title = flattenArray(title);
767
- }
768
- updateAttributes("title", attributes);
769
- };
770
- var commitTagChanges = (newState, cb) => {
771
- const {
772
- baseTag,
773
- bodyAttributes,
774
- htmlAttributes,
775
- linkTags,
776
- metaTags,
777
- noscriptTags,
778
- onChangeClientState,
779
- scriptTags,
780
- styleTags,
290
+ }
291
+ function generatePodcastSchema(data) {
292
+ return {
293
+ "@context": "https://schema.org",
294
+ "@type": "PodcastSeries",
295
+ "name": data.name,
296
+ "description": data.description,
297
+ "image": data.image,
298
+ "author": data.author ? {
299
+ "@type": "Person",
300
+ "name": data.author
301
+ } : void 0,
302
+ "webFeed": data.webFeed,
303
+ "url": data.url,
304
+ "genre": data.genre
305
+ };
306
+ }
307
+ function generatePodcastEpisodeSchema(data) {
308
+ return {
309
+ "@context": "https://schema.org",
310
+ "@type": "PodcastEpisode",
311
+ "name": data.name,
312
+ "description": data.description,
313
+ "datePublished": data.datePublished,
314
+ "timeRequired": data.duration,
315
+ "url": data.url,
316
+ "associatedMedia": data.audio ? {
317
+ "@type": "AudioObject",
318
+ "contentUrl": data.audio
319
+ } : void 0,
320
+ "partOfSeries": data.partOfSeries ? {
321
+ "@type": "PodcastSeries",
322
+ "name": data.partOfSeries.name,
323
+ "url": data.partOfSeries.url
324
+ } : void 0
325
+ };
326
+ }
327
+
328
+ // src/core/metadata.ts
329
+ function toNextMetadata(props, config) {
330
+ const title = props.title ? `${props.title} | ${config.name}` : config.name;
331
+ const description = props.description || config.description;
332
+ const url = props.canonical || config.url;
333
+ const image = props.image || config.logo;
334
+ const metadata = {
781
335
  title,
782
- titleAttributes
783
- } = newState;
784
- updateAttributes("body", bodyAttributes);
785
- updateAttributes("html", htmlAttributes);
786
- updateTitle(title, titleAttributes);
787
- const tagUpdates = {
788
- baseTag: updateTags("base", baseTag),
789
- linkTags: updateTags("link", linkTags),
790
- metaTags: updateTags("meta", metaTags),
791
- noscriptTags: updateTags("noscript", noscriptTags),
792
- scriptTags: updateTags("script", scriptTags),
793
- styleTags: updateTags("style", styleTags)
336
+ description,
337
+ keywords: props.keywords,
338
+ robots: props.noindex ? "noindex, nofollow" : props.robots || "index, follow",
339
+ alternates: {
340
+ canonical: props.noindex ? void 0 : url
341
+ },
342
+ openGraph: {
343
+ title: props.ogTitle || title,
344
+ description: props.ogDescription || description,
345
+ url,
346
+ siteName: config.name,
347
+ images: props.ogImage || image ? [{
348
+ url: props.ogImage || image,
349
+ width: props.ogImageWidth || 1200,
350
+ height: props.ogImageHeight || 630,
351
+ alt: props.ogImageAlt || title
352
+ }] : [],
353
+ type: props.ogType || (props.type === "article" ? "article" : "website"),
354
+ locale: props.ogLocale || config.language || "ar_SA"
355
+ },
356
+ twitter: {
357
+ card: props.twitterCard || "summary_large_image",
358
+ title: props.twitterTitle || title,
359
+ description: props.twitterDescription || description,
360
+ images: props.twitterImage || image ? [{
361
+ url: props.twitterImage || image,
362
+ alt: props.twitterImageAlt || title
363
+ }] : [],
364
+ site: config.twitterHandle,
365
+ creator: config.twitterHandle
366
+ },
367
+ other: {}
794
368
  };
795
- const addedTags = {};
796
- const removedTags = {};
797
- Object.keys(tagUpdates).forEach((tagType) => {
798
- const { newTags, oldTags } = tagUpdates[tagType];
799
- if (newTags.length) {
800
- addedTags[tagType] = newTags;
801
- }
802
- if (oldTags.length) {
803
- removedTags[tagType] = tagUpdates[tagType].oldTags;
804
- }
805
- });
806
- if (cb) {
807
- cb();
808
- }
809
- onChangeClientState(newState, addedTags, removedTags);
810
- };
811
- var _helmetCallback = null;
812
- var handleStateChangeOnClient = (newState) => {
813
- if (_helmetCallback) {
814
- cancelAnimationFrame(_helmetCallback);
815
- }
816
- if (newState.defer) {
817
- _helmetCallback = requestAnimationFrame(() => {
818
- commitTagChanges(newState, () => {
819
- _helmetCallback = null;
820
- });
369
+ if (props.alternates && props.alternates.length > 0) {
370
+ const languages = {};
371
+ props.alternates.forEach((alt) => {
372
+ languages[alt.hreflang] = alt.href;
821
373
  });
822
- } else {
823
- commitTagChanges(newState);
824
- _helmetCallback = null;
825
- }
826
- };
827
- var client_default = handleStateChangeOnClient;
828
- var HelmetDispatcher = class extends import_react4.Component {
829
- rendered = false;
830
- shouldComponentUpdate(nextProps) {
831
- return !(0, import_shallowequal.default)(nextProps, this.props);
832
- }
833
- componentDidUpdate() {
834
- this.emitChange();
835
- }
836
- componentWillUnmount() {
837
- const { helmetInstances } = this.props.context;
838
- helmetInstances.remove(this);
839
- this.emitChange();
840
- }
841
- emitChange() {
842
- const { helmetInstances, setHelmet } = this.props.context;
843
- let serverState = null;
844
- const state = reducePropsToState(
845
- helmetInstances.get().map((instance) => {
846
- const props = { ...instance.props };
847
- delete props.context;
848
- return props;
849
- })
850
- );
851
- if (HelmetProvider.canUseDOM) {
852
- client_default(state);
853
- } else if (server_default) {
854
- serverState = server_default(state);
855
- }
856
- setHelmet(serverState);
857
- }
858
- // componentWillMount will be deprecated
859
- // for SSR, initialize on first render
860
- // constructor is also unsafe in StrictMode
861
- init() {
862
- if (this.rendered) {
863
- return;
864
- }
865
- this.rendered = true;
866
- const { helmetInstances } = this.props.context;
867
- helmetInstances.add(this);
868
- this.emitChange();
869
- }
870
- render() {
871
- this.init();
872
- return null;
374
+ metadata.alternates.languages = languages;
873
375
  }
874
- };
875
- var Helmet = class extends import_react.Component {
876
- static defaultProps = {
877
- defer: true,
878
- encodeSpecialCharacters: true,
879
- prioritizeSeoTags: false
376
+ metadata.appleWebApp = {
377
+ capable: true,
378
+ title: config.name,
379
+ statusBarStyle: "default"
880
380
  };
881
- shouldComponentUpdate(nextProps) {
882
- return !(0, import_react_fast_compare.default)(without(this.props, "helmetData"), without(nextProps, "helmetData"));
883
- }
884
- mapNestedChildrenToProps(child, nestedChildren) {
885
- if (!nestedChildren) {
886
- return null;
887
- }
888
- switch (child.type) {
889
- case "script":
890
- case "noscript":
891
- return {
892
- innerHTML: nestedChildren
893
- };
894
- case "style":
895
- return {
896
- cssText: nestedChildren
897
- };
898
- default:
899
- throw new Error(
900
- `<${child.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`
901
- );
902
- }
903
- }
904
- flattenArrayTypeChildren(child, arrayTypeChildren, newChildProps, nestedChildren) {
905
- return {
906
- ...arrayTypeChildren,
907
- [child.type]: [
908
- ...arrayTypeChildren[child.type] || [],
909
- {
910
- ...newChildProps,
911
- ...this.mapNestedChildrenToProps(child, nestedChildren)
912
- }
913
- ]
914
- };
915
- }
916
- mapObjectTypeChildren(child, newProps, newChildProps, nestedChildren) {
917
- switch (child.type) {
918
- case "title":
919
- return {
920
- ...newProps,
921
- [child.type]: nestedChildren,
922
- titleAttributes: { ...newChildProps }
923
- };
924
- case "body":
925
- return {
926
- ...newProps,
927
- bodyAttributes: { ...newChildProps }
928
- };
929
- case "html":
930
- return {
931
- ...newProps,
932
- htmlAttributes: { ...newChildProps }
933
- };
934
- default:
935
- return {
936
- ...newProps,
937
- [child.type]: { ...newChildProps }
938
- };
939
- }
940
- }
941
- mapArrayTypeChildrenToProps(arrayTypeChildren, newProps) {
942
- let newFlattenedProps = { ...newProps };
943
- Object.keys(arrayTypeChildren).forEach((arrayChildName) => {
944
- newFlattenedProps = {
945
- ...newFlattenedProps,
946
- [arrayChildName]: arrayTypeChildren[arrayChildName]
947
- };
948
- });
949
- return newFlattenedProps;
950
- }
951
- warnOnInvalidChildren(child, nestedChildren) {
952
- (0, import_invariant.default)(
953
- VALID_TAG_NAMES.some((name) => child.type === name),
954
- 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(
955
- ", "
956
- )} are allowed. Helmet does not support rendering <${child.type}> elements. Refer to our API for more information.`
957
- );
958
- (0, import_invariant.default)(
959
- !nestedChildren || typeof nestedChildren === "string" || Array.isArray(nestedChildren) && !nestedChildren.some((nestedChild) => typeof nestedChild !== "string"),
960
- `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.`
961
- );
962
- return true;
963
- }
964
- mapChildrenToProps(children, newProps) {
965
- let arrayTypeChildren = {};
966
- import_react.default.Children.forEach(children, (child) => {
967
- if (!child || !child.props) {
968
- return;
969
- }
970
- const { children: nestedChildren, ...childProps } = child.props;
971
- const newChildProps = Object.keys(childProps).reduce((obj, key) => {
972
- obj[HTML_TAG_MAP[key] || key] = childProps[key];
973
- return obj;
974
- }, {});
975
- let { type } = child;
976
- if (typeof type === "symbol") {
977
- type = type.toString();
978
- } else {
979
- this.warnOnInvalidChildren(child, nestedChildren);
980
- }
981
- switch (type) {
982
- case "Symbol(react.fragment)":
983
- newProps = this.mapChildrenToProps(nestedChildren, newProps);
984
- break;
985
- case "link":
986
- case "meta":
987
- case "noscript":
988
- case "script":
989
- case "style":
990
- arrayTypeChildren = this.flattenArrayTypeChildren(
991
- child,
992
- arrayTypeChildren,
993
- newChildProps,
994
- nestedChildren
995
- );
996
- break;
997
- default:
998
- newProps = this.mapObjectTypeChildren(child, newProps, newChildProps, nestedChildren);
999
- break;
1000
- }
1001
- });
1002
- return this.mapArrayTypeChildrenToProps(arrayTypeChildren, newProps);
1003
- }
1004
- render() {
1005
- const { children, ...props } = this.props;
1006
- let newProps = { ...props };
1007
- let { helmetData } = props;
1008
- if (children) {
1009
- newProps = this.mapChildrenToProps(children, newProps);
1010
- }
1011
- if (helmetData && !(helmetData instanceof HelmetData)) {
1012
- const data = helmetData;
1013
- helmetData = new HelmetData(data.context, true);
1014
- delete newProps.helmetData;
1015
- }
1016
- return helmetData ? /* @__PURE__ */ import_react.default.createElement(HelmetDispatcher, { ...newProps, context: helmetData.value }) : /* @__PURE__ */ import_react.default.createElement(Context.Consumer, null, (context) => /* @__PURE__ */ import_react.default.createElement(HelmetDispatcher, { ...newProps, context }));
1017
- }
1018
- };
381
+ if (config.themeColor) metadata.themeColor = config.themeColor;
382
+ if (config.manifest) metadata.manifest = config.manifest;
383
+ return metadata;
384
+ }
385
+ function generatePaginationLinks(baseUrl, currentPage, totalPages) {
386
+ const hasNext = currentPage < totalPages;
387
+ const hasPrev = currentPage > 1;
388
+ const cleanBase = baseUrl.split("?")[0];
389
+ return {
390
+ next: hasNext ? `${cleanBase}?page=${currentPage + 1}` : void 0,
391
+ prev: hasPrev ? currentPage === 2 ? cleanBase : `${cleanBase}?page=${currentPage - 1}` : void 0,
392
+ canonical: currentPage === 1 ? cleanBase : `${cleanBase}?page=${currentPage}`
393
+ };
394
+ }
395
+ function generatePaginatedTitle(title, page, suffix = "\u0635\u0641\u062D\u0629") {
396
+ return page > 1 ? `${title} - ${suffix} ${page}` : title;
397
+ }
1019
398
 
1020
399
  // src/components/SEOProvider.tsx
400
+ var import_react = require("react");
401
+ var import_react_helmet_async = require("react-helmet-async");
1021
402
  var import_jsx_runtime = require("react/jsx-runtime");
1022
- var SEOContext = (0, import_react5.createContext)(void 0);
403
+ var SEOContext = (0, import_react.createContext)(void 0);
1023
404
  var SEOProvider = ({ config, children, helmetContext }) => {
1024
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SEOContext.Provider, { value: { config }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(HelmetProvider, { context: helmetContext, children }) });
405
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SEOContext.Provider, { value: { config }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_helmet_async.HelmetProvider, { context: helmetContext, children }) });
1025
406
  };
1026
407
  var useSEOConfig = () => {
1027
- const context = (0, import_react5.useContext)(SEOContext);
408
+ const context = (0, import_react.useContext)(SEOContext);
1028
409
  if (!context) {
1029
410
  throw new Error("useSEOConfig must be used within an SEOProvider");
1030
411
  }
@@ -1032,6 +413,7 @@ var useSEOConfig = () => {
1032
413
  };
1033
414
 
1034
415
  // src/components/SEO.tsx
416
+ var import_react_helmet_async2 = require("react-helmet-async");
1035
417
  var import_jsx_runtime2 = require("react/jsx-runtime");
1036
418
  var SEO = (props) => {
1037
419
  const config = useSEOConfig();
@@ -1111,7 +493,7 @@ var SEO = (props) => {
1111
493
  schemas.push(props.schema);
1112
494
  }
1113
495
  }
1114
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Helmet, { children: [
496
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_helmet_async2.Helmet, { children: [
1115
497
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("title", { children: title }),
1116
498
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("meta", { name: "description", content: description }),
1117
499
  props.keywords && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("meta", { name: "keywords", content: props.keywords.join(", ") }),
@@ -1160,6 +542,7 @@ var SEO = (props) => {
1160
542
  };
1161
543
 
1162
544
  // src/components/Breadcrumb.tsx
545
+ var import_react_helmet_async3 = require("react-helmet-async");
1163
546
  var import_jsx_runtime3 = require("react/jsx-runtime");
1164
547
  var Breadcrumb = ({
1165
548
  items,
@@ -1178,7 +561,7 @@ var Breadcrumb = ({
1178
561
  }))
1179
562
  };
1180
563
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
1181
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) }),
564
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_helmet_async3.Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) }),
1182
565
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("nav", { className, "aria-label": "Breadcrumb", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("ol", { style: { display: "flex", listStyle: "none", padding: 0 }, children: items.map((item, index) => {
1183
566
  const isLast = index === items.length - 1;
1184
567
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("li", { style: { display: "flex", alignItems: "center" }, children: [
@@ -1234,6 +617,7 @@ var SeoProduct = ({ item, ...rest }) => {
1234
617
  };
1235
618
 
1236
619
  // src/components/SeoFAQ.tsx
620
+ var import_react_helmet_async4 = require("react-helmet-async");
1237
621
  var import_jsx_runtime6 = require("react/jsx-runtime");
1238
622
  var SeoFAQ = ({ items }) => {
1239
623
  const schema = {
@@ -1248,10 +632,11 @@ var SeoFAQ = ({ items }) => {
1248
632
  }
1249
633
  }))
1250
634
  };
1251
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
635
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_helmet_async4.Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
1252
636
  };
1253
637
 
1254
638
  // src/components/SeoVideo.tsx
639
+ var import_react_helmet_async5 = require("react-helmet-async");
1255
640
  var import_jsx_runtime7 = require("react/jsx-runtime");
1256
641
  var SeoVideo = ({ video }) => {
1257
642
  const schema = {
@@ -1270,10 +655,11 @@ var SeoVideo = ({ video }) => {
1270
655
  "userInteractionCount": video.interactionStatistic.viewCount
1271
656
  } : void 0
1272
657
  };
1273
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
658
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_helmet_async5.Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
1274
659
  };
1275
660
 
1276
661
  // src/components/SeoEvent.tsx
662
+ var import_react_helmet_async6 = require("react-helmet-async");
1277
663
  var import_jsx_runtime8 = require("react/jsx-runtime");
1278
664
  var SeoEvent = ({ event }) => {
1279
665
  const schema = {
@@ -1310,10 +696,11 @@ var SeoEvent = ({ event }) => {
1310
696
  "url": event.organizer.url
1311
697
  } : void 0
1312
698
  };
1313
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
699
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_helmet_async6.Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
1314
700
  };
1315
701
 
1316
702
  // src/components/SeoLocalBusiness.tsx
703
+ var import_react_helmet_async7 = require("react-helmet-async");
1317
704
  var import_jsx_runtime9 = require("react/jsx-runtime");
1318
705
  var SeoLocalBusiness = ({ business }) => {
1319
706
  const schema = {
@@ -1341,7 +728,7 @@ var SeoLocalBusiness = ({ business }) => {
1341
728
  } : void 0,
1342
729
  "openingHours": business.openingHours
1343
730
  };
1344
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
731
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_helmet_async7.Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
1345
732
  };
1346
733
 
1347
734
  // src/components/SeoCategory.tsx
@@ -1432,6 +819,7 @@ var SeoAuthor = ({ author, page = 1, totalPage = 1, ...rest }) => {
1432
819
  };
1433
820
 
1434
821
  // src/components/SeoHowTo.tsx
822
+ var import_react_helmet_async8 = require("react-helmet-async");
1435
823
  var import_jsx_runtime13 = require("react/jsx-runtime");
1436
824
  var SeoHowTo = ({ name, description, image, steps }) => {
1437
825
  const schema = {
@@ -1458,10 +846,11 @@ var SeoHowTo = ({ name, description, image, steps }) => {
1458
846
  };
1459
847
  })
1460
848
  };
1461
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
849
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_helmet_async8.Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
1462
850
  };
1463
851
 
1464
852
  // src/components/SeoReview.tsx
853
+ var import_react_helmet_async9 = require("react-helmet-async");
1465
854
  var import_jsx_runtime14 = require("react/jsx-runtime");
1466
855
  var SeoReview = ({ itemReviewed, review }) => {
1467
856
  const schema = {
@@ -1485,10 +874,11 @@ var SeoReview = ({ itemReviewed, review }) => {
1485
874
  "worstRating": review.worstRating || 1
1486
875
  }
1487
876
  };
1488
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
877
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_helmet_async9.Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
1489
878
  };
1490
879
 
1491
880
  // src/components/SeoCourse.tsx
881
+ var import_react_helmet_async10 = require("react-helmet-async");
1492
882
  var import_jsx_runtime15 = require("react/jsx-runtime");
1493
883
  var SeoCourse = ({ course }) => {
1494
884
  const schema = {
@@ -1503,10 +893,11 @@ var SeoCourse = ({ course }) => {
1503
893
  },
1504
894
  "image": course.image
1505
895
  };
1506
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
896
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_helmet_async10.Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
1507
897
  };
1508
898
 
1509
899
  // src/components/SeoRecipe.tsx
900
+ var import_react_helmet_async11 = require("react-helmet-async");
1510
901
  var import_jsx_runtime16 = require("react/jsx-runtime");
1511
902
  var SeoRecipe = ({ recipe }) => {
1512
903
  const schema = {
@@ -1534,10 +925,11 @@ var SeoRecipe = ({ recipe }) => {
1534
925
  "image": step.image
1535
926
  }))
1536
927
  };
1537
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
928
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_helmet_async11.Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
1538
929
  };
1539
930
 
1540
931
  // src/components/SeoJobPosting.tsx
932
+ var import_react_helmet_async12 = require("react-helmet-async");
1541
933
  var import_jsx_runtime17 = require("react/jsx-runtime");
1542
934
  var SeoJobPosting = ({ job }) => {
1543
935
  const schema = {
@@ -1580,59 +972,8 @@ var SeoJobPosting = ({ job }) => {
1580
972
  }
1581
973
  } : void 0
1582
974
  };
1583
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
975
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_helmet_async12.Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("script", { type: "application/ld+json", children: JSON.stringify(schema) }) });
1584
976
  };
1585
-
1586
- // src/utils/next-adapter.ts
1587
- function toNextMetadata(props, config) {
1588
- const title = props.title ? `${props.title} | ${config.name}` : config.name;
1589
- const description = props.description || config.description;
1590
- const url = props.canonical || config.url;
1591
- const image = props.image || config.logo;
1592
- const metadata = {
1593
- title,
1594
- description,
1595
- keywords: props.keywords,
1596
- robots: props.noindex ? "noindex, nofollow" : props.robots || "index, follow",
1597
- alternates: {
1598
- canonical: props.noindex ? void 0 : url
1599
- },
1600
- openGraph: {
1601
- title: props.ogTitle || title,
1602
- description: props.ogDescription || description,
1603
- url,
1604
- siteName: config.name,
1605
- images: props.ogImage || image ? [{ url: props.ogImage || image }] : [],
1606
- type: props.ogType || (props.type === "article" ? "article" : "website"),
1607
- locale: props.ogLocale || config.language || "ar_SA"
1608
- },
1609
- twitter: {
1610
- card: props.twitterCard || "summary_large_image",
1611
- title: props.twitterTitle || title,
1612
- description: props.twitterDescription || description,
1613
- images: props.twitterImage || image ? [props.twitterImage || image] : [],
1614
- site: config.twitterHandle,
1615
- creator: config.twitterHandle
1616
- },
1617
- other: {}
1618
- };
1619
- if (props.alternates && props.alternates.length > 0) {
1620
- const languages = {};
1621
- props.alternates.forEach((alt) => {
1622
- languages[alt.hreflang] = alt.href;
1623
- });
1624
- metadata.alternates.languages = languages;
1625
- }
1626
- metadata.appleWebApp = {
1627
- capable: true,
1628
- title: config.name,
1629
- statusBarStyle: "default"
1630
- };
1631
- if (props.dnsPrefetch) metadata.other["dns-prefetch"] = props.dnsPrefetch;
1632
- if (config.themeColor) metadata.themeColor = config.themeColor;
1633
- if (config.manifest) metadata.manifest = config.manifest;
1634
- return metadata;
1635
- }
1636
977
  // Annotate the CommonJS export names for ESM import in node:
1637
978
  0 && (module.exports = {
1638
979
  Breadcrumb,
@@ -1652,6 +993,22 @@ function toNextMetadata(props, config) {
1652
993
  SeoReview,
1653
994
  SeoTag,
1654
995
  SeoVideo,
996
+ generateArticleSchema,
997
+ generateBookSchema,
998
+ generateBreadcrumbSchema,
999
+ generateEventSchema,
1000
+ generateFAQSchema,
1001
+ generateLocalBusinessSchema,
1002
+ generateMovieSchema,
1003
+ generateOrganizationSchema,
1004
+ generatePaginatedTitle,
1005
+ generatePaginationLinks,
1006
+ generatePodcastEpisodeSchema,
1007
+ generatePodcastSchema,
1008
+ generateProductSchema,
1009
+ generateSoftwareSchema,
1010
+ generateVideoSchema,
1011
+ generateWebSiteSchema,
1655
1012
  toNextMetadata,
1656
1013
  useSEOConfig
1657
1014
  });