@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/README.md +142 -91
- package/dist/chunk-AAN7NRZE.mjs +235 -0
- package/dist/chunk-QD5UVA5B.mjs +357 -0
- package/dist/core/index.d.mts +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +399 -0
- package/dist/core/index.mjs +38 -0
- package/dist/index-BEY3UKjK.d.mts +538 -0
- package/dist/index-BEY3UKjK.d.ts +538 -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 +375 -1018
- package/dist/index.mjs +57 -1047
- package/package.json +32 -12
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/core/index.ts
|
|
21
|
+
var core_exports = {};
|
|
22
|
+
__export(core_exports, {
|
|
23
|
+
generateArticleSchema: () => generateArticleSchema,
|
|
24
|
+
generateBookSchema: () => generateBookSchema,
|
|
25
|
+
generateBreadcrumbSchema: () => generateBreadcrumbSchema,
|
|
26
|
+
generateEventSchema: () => generateEventSchema,
|
|
27
|
+
generateFAQSchema: () => generateFAQSchema,
|
|
28
|
+
generateLocalBusinessSchema: () => generateLocalBusinessSchema,
|
|
29
|
+
generateMovieSchema: () => generateMovieSchema,
|
|
30
|
+
generateOrganizationSchema: () => generateOrganizationSchema,
|
|
31
|
+
generatePaginatedTitle: () => generatePaginatedTitle,
|
|
32
|
+
generatePaginationLinks: () => generatePaginationLinks,
|
|
33
|
+
generatePodcastEpisodeSchema: () => generatePodcastEpisodeSchema,
|
|
34
|
+
generatePodcastSchema: () => generatePodcastSchema,
|
|
35
|
+
generateProductSchema: () => generateProductSchema,
|
|
36
|
+
generateSoftwareSchema: () => generateSoftwareSchema,
|
|
37
|
+
generateVideoSchema: () => generateVideoSchema,
|
|
38
|
+
generateWebSiteSchema: () => generateWebSiteSchema,
|
|
39
|
+
toNextMetadata: () => toNextMetadata
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(core_exports);
|
|
42
|
+
|
|
43
|
+
// src/core/schemas.ts
|
|
44
|
+
function generateOrganizationSchema(config) {
|
|
45
|
+
return {
|
|
46
|
+
"@context": "https://schema.org",
|
|
47
|
+
"@type": "Organization",
|
|
48
|
+
"name": config.name,
|
|
49
|
+
"url": config.url,
|
|
50
|
+
"logo": config.logo,
|
|
51
|
+
"sameAs": config.socialLinks || []
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function generateWebSiteSchema(config) {
|
|
55
|
+
return {
|
|
56
|
+
"@context": "https://schema.org",
|
|
57
|
+
"@type": "WebSite",
|
|
58
|
+
"name": config.name,
|
|
59
|
+
"url": config.url,
|
|
60
|
+
"potentialAction": {
|
|
61
|
+
"@type": "SearchAction",
|
|
62
|
+
"target": `${config.url}/search?q={search_term_string}`,
|
|
63
|
+
"query-input": "required name=search_term_string"
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function generateArticleSchema(data, config) {
|
|
68
|
+
const org = generateOrganizationSchema(config);
|
|
69
|
+
return {
|
|
70
|
+
"@context": "https://schema.org",
|
|
71
|
+
"@type": "NewsArticle",
|
|
72
|
+
"headline": data.title,
|
|
73
|
+
"description": data.description,
|
|
74
|
+
"image": data.image || config.logo,
|
|
75
|
+
"datePublished": data.publishedTime,
|
|
76
|
+
"dateModified": data.modifiedTime || data.publishedTime,
|
|
77
|
+
"mainEntityOfPage": data.url,
|
|
78
|
+
"author": data.author ? {
|
|
79
|
+
"@type": "Person",
|
|
80
|
+
"name": data.author.name,
|
|
81
|
+
"url": data.author.url
|
|
82
|
+
} : org,
|
|
83
|
+
"publisher": org
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function generateProductSchema(data) {
|
|
87
|
+
return {
|
|
88
|
+
"@context": "https://schema.org",
|
|
89
|
+
"@type": "Product",
|
|
90
|
+
"name": data.name,
|
|
91
|
+
"description": data.description,
|
|
92
|
+
"image": data.image,
|
|
93
|
+
"sku": data.sku,
|
|
94
|
+
"brand": data.brand ? { "@type": "Brand", "name": data.brand } : void 0,
|
|
95
|
+
"offers": {
|
|
96
|
+
"@type": "Offer",
|
|
97
|
+
"url": data.url,
|
|
98
|
+
"priceCurrency": data.currency || "USD",
|
|
99
|
+
"price": data.price,
|
|
100
|
+
"availability": data.availability || "https://schema.org/InStock"
|
|
101
|
+
},
|
|
102
|
+
"aggregateRating": data.rating ? {
|
|
103
|
+
"@type": "AggregateRating",
|
|
104
|
+
"ratingValue": data.rating,
|
|
105
|
+
"reviewCount": data.reviewCount || 1
|
|
106
|
+
} : void 0
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function generateFAQSchema(questions) {
|
|
110
|
+
return {
|
|
111
|
+
"@context": "https://schema.org",
|
|
112
|
+
"@type": "FAQPage",
|
|
113
|
+
"mainEntity": questions.map((item) => ({
|
|
114
|
+
"@type": "Question",
|
|
115
|
+
"name": item.q,
|
|
116
|
+
"acceptedAnswer": {
|
|
117
|
+
"@type": "Answer",
|
|
118
|
+
"text": item.a
|
|
119
|
+
}
|
|
120
|
+
}))
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function generateBreadcrumbSchema(items) {
|
|
124
|
+
return {
|
|
125
|
+
"@context": "https://schema.org",
|
|
126
|
+
"@type": "BreadcrumbList",
|
|
127
|
+
"itemListElement": items.map((item, index) => ({
|
|
128
|
+
"@type": "ListItem",
|
|
129
|
+
"position": index + 1,
|
|
130
|
+
"name": item.name,
|
|
131
|
+
"item": item.item
|
|
132
|
+
}))
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function generateVideoSchema(data) {
|
|
136
|
+
return {
|
|
137
|
+
"@context": "https://schema.org",
|
|
138
|
+
"@type": "VideoObject",
|
|
139
|
+
"name": data.name,
|
|
140
|
+
"description": data.description,
|
|
141
|
+
"thumbnailUrl": data.thumbnailUrl,
|
|
142
|
+
"uploadDate": data.uploadDate,
|
|
143
|
+
"duration": data.duration,
|
|
144
|
+
"contentUrl": data.contentUrl,
|
|
145
|
+
"embedUrl": data.embedUrl
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function generateEventSchema(data) {
|
|
149
|
+
const isOnline = data.location && "url" in data.location;
|
|
150
|
+
return {
|
|
151
|
+
"@context": "https://schema.org",
|
|
152
|
+
"@type": "Event",
|
|
153
|
+
"name": data.name,
|
|
154
|
+
"description": data.description,
|
|
155
|
+
"startDate": data.startDate,
|
|
156
|
+
"endDate": data.endDate,
|
|
157
|
+
"eventAttendanceMode": isOnline ? "https://schema.org/OnlineEventAttendanceMode" : "https://schema.org/OfflineEventAttendanceMode",
|
|
158
|
+
"location": isOnline ? {
|
|
159
|
+
"@type": "VirtualLocation",
|
|
160
|
+
"url": data.location.url
|
|
161
|
+
} : data.location ? {
|
|
162
|
+
"@type": "Place",
|
|
163
|
+
"name": data.location.name,
|
|
164
|
+
"address": data.location.address
|
|
165
|
+
} : void 0,
|
|
166
|
+
"image": data.image,
|
|
167
|
+
"offers": data.offers ? {
|
|
168
|
+
"@type": "Offer",
|
|
169
|
+
"price": data.offers.price,
|
|
170
|
+
"priceCurrency": data.offers.currency,
|
|
171
|
+
"url": data.offers.url
|
|
172
|
+
} : void 0
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function generateLocalBusinessSchema(data) {
|
|
176
|
+
return {
|
|
177
|
+
"@context": "https://schema.org",
|
|
178
|
+
"@type": "LocalBusiness",
|
|
179
|
+
"name": data.name,
|
|
180
|
+
"description": data.description,
|
|
181
|
+
"image": data.image,
|
|
182
|
+
"telephone": data.telephone,
|
|
183
|
+
"address": {
|
|
184
|
+
"@type": "PostalAddress",
|
|
185
|
+
"streetAddress": data.address.street,
|
|
186
|
+
"addressLocality": data.address.city,
|
|
187
|
+
"addressRegion": data.address.region,
|
|
188
|
+
"postalCode": data.address.postalCode,
|
|
189
|
+
"addressCountry": data.address.country
|
|
190
|
+
},
|
|
191
|
+
"geo": data.geo ? {
|
|
192
|
+
"@type": "GeoCoordinates",
|
|
193
|
+
"latitude": data.geo.lat,
|
|
194
|
+
"longitude": data.geo.lng
|
|
195
|
+
} : void 0,
|
|
196
|
+
"openingHours": data.openingHours,
|
|
197
|
+
"priceRange": data.priceRange
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function generateSoftwareSchema(data) {
|
|
201
|
+
return {
|
|
202
|
+
"@context": "https://schema.org",
|
|
203
|
+
"@type": "SoftwareApplication",
|
|
204
|
+
"name": data.name,
|
|
205
|
+
"description": data.description,
|
|
206
|
+
"operatingSystem": data.operatingSystem,
|
|
207
|
+
"applicationCategory": data.applicationCategory,
|
|
208
|
+
"offers": data.offers ? {
|
|
209
|
+
"@type": "Offer",
|
|
210
|
+
"price": data.offers.price,
|
|
211
|
+
"priceCurrency": data.offers.currency
|
|
212
|
+
} : void 0,
|
|
213
|
+
"aggregateRating": data.rating ? {
|
|
214
|
+
"@type": "AggregateRating",
|
|
215
|
+
"ratingValue": data.rating,
|
|
216
|
+
"reviewCount": data.reviewCount || 1
|
|
217
|
+
} : void 0,
|
|
218
|
+
"downloadUrl": data.downloadUrl,
|
|
219
|
+
"screenshot": data.screenshot
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
function generateBookSchema(data) {
|
|
223
|
+
return {
|
|
224
|
+
"@context": "https://schema.org",
|
|
225
|
+
"@type": "Book",
|
|
226
|
+
"name": data.name,
|
|
227
|
+
"author": typeof data.author === "string" ? {
|
|
228
|
+
"@type": "Person",
|
|
229
|
+
"name": data.author
|
|
230
|
+
} : {
|
|
231
|
+
"@type": "Person",
|
|
232
|
+
"name": data.author.name,
|
|
233
|
+
"url": data.author.url
|
|
234
|
+
},
|
|
235
|
+
"description": data.description,
|
|
236
|
+
"isbn": data.isbn,
|
|
237
|
+
"numberOfPages": data.numberOfPages,
|
|
238
|
+
"publisher": data.publisher ? {
|
|
239
|
+
"@type": "Organization",
|
|
240
|
+
"name": data.publisher
|
|
241
|
+
} : void 0,
|
|
242
|
+
"datePublished": data.datePublished,
|
|
243
|
+
"image": data.image,
|
|
244
|
+
"inLanguage": data.inLanguage,
|
|
245
|
+
"genre": data.genre
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function generateMovieSchema(data) {
|
|
249
|
+
return {
|
|
250
|
+
"@context": "https://schema.org",
|
|
251
|
+
"@type": "Movie",
|
|
252
|
+
"name": data.name,
|
|
253
|
+
"description": data.description,
|
|
254
|
+
"image": data.image,
|
|
255
|
+
"director": data.director ? {
|
|
256
|
+
"@type": "Person",
|
|
257
|
+
"name": data.director
|
|
258
|
+
} : void 0,
|
|
259
|
+
"actor": data.actor?.map((name) => ({
|
|
260
|
+
"@type": "Person",
|
|
261
|
+
"name": name
|
|
262
|
+
})),
|
|
263
|
+
"dateCreated": data.dateCreated,
|
|
264
|
+
"duration": data.duration,
|
|
265
|
+
"genre": data.genre,
|
|
266
|
+
"aggregateRating": data.rating ? {
|
|
267
|
+
"@type": "AggregateRating",
|
|
268
|
+
"ratingValue": data.rating,
|
|
269
|
+
"reviewCount": data.reviewCount || 1
|
|
270
|
+
} : void 0
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
function generatePodcastSchema(data) {
|
|
274
|
+
return {
|
|
275
|
+
"@context": "https://schema.org",
|
|
276
|
+
"@type": "PodcastSeries",
|
|
277
|
+
"name": data.name,
|
|
278
|
+
"description": data.description,
|
|
279
|
+
"image": data.image,
|
|
280
|
+
"author": data.author ? {
|
|
281
|
+
"@type": "Person",
|
|
282
|
+
"name": data.author
|
|
283
|
+
} : void 0,
|
|
284
|
+
"webFeed": data.webFeed,
|
|
285
|
+
"url": data.url,
|
|
286
|
+
"genre": data.genre
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
function generatePodcastEpisodeSchema(data) {
|
|
290
|
+
return {
|
|
291
|
+
"@context": "https://schema.org",
|
|
292
|
+
"@type": "PodcastEpisode",
|
|
293
|
+
"name": data.name,
|
|
294
|
+
"description": data.description,
|
|
295
|
+
"datePublished": data.datePublished,
|
|
296
|
+
"timeRequired": data.duration,
|
|
297
|
+
"url": data.url,
|
|
298
|
+
"associatedMedia": data.audio ? {
|
|
299
|
+
"@type": "AudioObject",
|
|
300
|
+
"contentUrl": data.audio
|
|
301
|
+
} : void 0,
|
|
302
|
+
"partOfSeries": data.partOfSeries ? {
|
|
303
|
+
"@type": "PodcastSeries",
|
|
304
|
+
"name": data.partOfSeries.name,
|
|
305
|
+
"url": data.partOfSeries.url
|
|
306
|
+
} : void 0
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// src/core/metadata.ts
|
|
311
|
+
function toNextMetadata(props, config) {
|
|
312
|
+
const title = props.title ? `${props.title} | ${config.name}` : config.name;
|
|
313
|
+
const description = props.description || config.description;
|
|
314
|
+
const url = props.canonical || config.url;
|
|
315
|
+
const image = props.image || config.logo;
|
|
316
|
+
const metadata = {
|
|
317
|
+
title,
|
|
318
|
+
description,
|
|
319
|
+
keywords: props.keywords,
|
|
320
|
+
robots: props.noindex ? "noindex, nofollow" : props.robots || "index, follow",
|
|
321
|
+
alternates: {
|
|
322
|
+
canonical: props.noindex ? void 0 : url
|
|
323
|
+
},
|
|
324
|
+
openGraph: {
|
|
325
|
+
title: props.ogTitle || title,
|
|
326
|
+
description: props.ogDescription || description,
|
|
327
|
+
url,
|
|
328
|
+
siteName: config.name,
|
|
329
|
+
images: props.ogImage || image ? [{
|
|
330
|
+
url: props.ogImage || image,
|
|
331
|
+
width: props.ogImageWidth || 1200,
|
|
332
|
+
height: props.ogImageHeight || 630,
|
|
333
|
+
alt: props.ogImageAlt || title
|
|
334
|
+
}] : [],
|
|
335
|
+
type: props.ogType || (props.type === "article" ? "article" : "website"),
|
|
336
|
+
locale: props.ogLocale || config.language || "ar_SA"
|
|
337
|
+
},
|
|
338
|
+
twitter: {
|
|
339
|
+
card: props.twitterCard || "summary_large_image",
|
|
340
|
+
title: props.twitterTitle || title,
|
|
341
|
+
description: props.twitterDescription || description,
|
|
342
|
+
images: props.twitterImage || image ? [{
|
|
343
|
+
url: props.twitterImage || image,
|
|
344
|
+
alt: props.twitterImageAlt || title
|
|
345
|
+
}] : [],
|
|
346
|
+
site: config.twitterHandle,
|
|
347
|
+
creator: config.twitterHandle
|
|
348
|
+
},
|
|
349
|
+
other: {}
|
|
350
|
+
};
|
|
351
|
+
if (props.alternates && props.alternates.length > 0) {
|
|
352
|
+
const languages = {};
|
|
353
|
+
props.alternates.forEach((alt) => {
|
|
354
|
+
languages[alt.hreflang] = alt.href;
|
|
355
|
+
});
|
|
356
|
+
metadata.alternates.languages = languages;
|
|
357
|
+
}
|
|
358
|
+
metadata.appleWebApp = {
|
|
359
|
+
capable: true,
|
|
360
|
+
title: config.name,
|
|
361
|
+
statusBarStyle: "default"
|
|
362
|
+
};
|
|
363
|
+
if (config.themeColor) metadata.themeColor = config.themeColor;
|
|
364
|
+
if (config.manifest) metadata.manifest = config.manifest;
|
|
365
|
+
return metadata;
|
|
366
|
+
}
|
|
367
|
+
function generatePaginationLinks(baseUrl, currentPage, totalPages) {
|
|
368
|
+
const hasNext = currentPage < totalPages;
|
|
369
|
+
const hasPrev = currentPage > 1;
|
|
370
|
+
const cleanBase = baseUrl.split("?")[0];
|
|
371
|
+
return {
|
|
372
|
+
next: hasNext ? `${cleanBase}?page=${currentPage + 1}` : void 0,
|
|
373
|
+
prev: hasPrev ? currentPage === 2 ? cleanBase : `${cleanBase}?page=${currentPage - 1}` : void 0,
|
|
374
|
+
canonical: currentPage === 1 ? cleanBase : `${cleanBase}?page=${currentPage}`
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
function generatePaginatedTitle(title, page, suffix = "\u0635\u0641\u062D\u0629") {
|
|
378
|
+
return page > 1 ? `${title} - ${suffix} ${page}` : title;
|
|
379
|
+
}
|
|
380
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
381
|
+
0 && (module.exports = {
|
|
382
|
+
generateArticleSchema,
|
|
383
|
+
generateBookSchema,
|
|
384
|
+
generateBreadcrumbSchema,
|
|
385
|
+
generateEventSchema,
|
|
386
|
+
generateFAQSchema,
|
|
387
|
+
generateLocalBusinessSchema,
|
|
388
|
+
generateMovieSchema,
|
|
389
|
+
generateOrganizationSchema,
|
|
390
|
+
generatePaginatedTitle,
|
|
391
|
+
generatePaginationLinks,
|
|
392
|
+
generatePodcastEpisodeSchema,
|
|
393
|
+
generatePodcastSchema,
|
|
394
|
+
generateProductSchema,
|
|
395
|
+
generateSoftwareSchema,
|
|
396
|
+
generateVideoSchema,
|
|
397
|
+
generateWebSiteSchema,
|
|
398
|
+
toNextMetadata
|
|
399
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
generateArticleSchema,
|
|
3
|
+
generateBookSchema,
|
|
4
|
+
generateBreadcrumbSchema,
|
|
5
|
+
generateEventSchema,
|
|
6
|
+
generateFAQSchema,
|
|
7
|
+
generateLocalBusinessSchema,
|
|
8
|
+
generateMovieSchema,
|
|
9
|
+
generateOrganizationSchema,
|
|
10
|
+
generatePaginatedTitle,
|
|
11
|
+
generatePaginationLinks,
|
|
12
|
+
generatePodcastEpisodeSchema,
|
|
13
|
+
generatePodcastSchema,
|
|
14
|
+
generateProductSchema,
|
|
15
|
+
generateSoftwareSchema,
|
|
16
|
+
generateVideoSchema,
|
|
17
|
+
generateWebSiteSchema,
|
|
18
|
+
toNextMetadata
|
|
19
|
+
} from "../chunk-QD5UVA5B.mjs";
|
|
20
|
+
export {
|
|
21
|
+
generateArticleSchema,
|
|
22
|
+
generateBookSchema,
|
|
23
|
+
generateBreadcrumbSchema,
|
|
24
|
+
generateEventSchema,
|
|
25
|
+
generateFAQSchema,
|
|
26
|
+
generateLocalBusinessSchema,
|
|
27
|
+
generateMovieSchema,
|
|
28
|
+
generateOrganizationSchema,
|
|
29
|
+
generatePaginatedTitle,
|
|
30
|
+
generatePaginationLinks,
|
|
31
|
+
generatePodcastEpisodeSchema,
|
|
32
|
+
generatePodcastSchema,
|
|
33
|
+
generateProductSchema,
|
|
34
|
+
generateSoftwareSchema,
|
|
35
|
+
generateVideoSchema,
|
|
36
|
+
generateWebSiteSchema,
|
|
37
|
+
toNextMetadata
|
|
38
|
+
};
|