@umituz/web-seo 2.0.4 → 2.0.6
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/domains/seo/components/index.d.ts +8 -0
- package/dist/domains/seo/components/index.d.ts.map +1 -0
- package/dist/domains/seo/components/index.js +7 -0
- package/dist/domains/seo/hooks/index.d.ts +8 -0
- package/dist/domains/seo/hooks/index.d.ts.map +1 -0
- package/dist/domains/seo/hooks/index.js +7 -0
- package/dist/domains/seo/ssr/renderer.d.ts +1 -1
- package/dist/domains/seo/ssr/renderer.d.ts.map +1 -1
- package/dist/domains/seo/types/index.d.ts +5 -1
- package/dist/domains/seo/types/index.d.ts.map +1 -1
- package/dist/domains/seo/utils/dom.d.ts +5 -3
- package/dist/domains/seo/utils/dom.d.ts.map +1 -1
- package/dist/domains/seo/utils/dom.js +9 -322
- package/dist/domains/seo/utils/index.d.ts +10 -0
- package/dist/domains/seo/utils/index.d.ts.map +1 -0
- package/dist/domains/seo/utils/index.js +13 -0
- package/dist/domains/seo/utils/meta-tags/advanced.d.ts +31 -0
- package/dist/domains/seo/utils/meta-tags/advanced.d.ts.map +1 -0
- package/dist/domains/seo/utils/meta-tags/advanced.js +75 -0
- package/dist/domains/seo/utils/meta-tags/basic.d.ts +19 -0
- package/dist/domains/seo/utils/meta-tags/basic.d.ts.map +1 -0
- package/dist/domains/seo/utils/meta-tags/basic.js +93 -0
- package/dist/domains/seo/utils/meta-tags/index.d.ts +10 -0
- package/dist/domains/seo/utils/meta-tags/index.d.ts.map +1 -0
- package/dist/domains/seo/utils/meta-tags/index.js +9 -0
- package/dist/domains/seo/utils/meta-tags/performance.d.ts +19 -0
- package/dist/domains/seo/utils/meta-tags/performance.d.ts.map +1 -0
- package/dist/domains/seo/utils/meta-tags/performance.js +63 -0
- package/dist/domains/seo/utils/meta-tags/social.d.ts +15 -0
- package/dist/domains/seo/utils/meta-tags/social.d.ts.map +1 -0
- package/dist/domains/seo/utils/meta-tags/social.js +132 -0
- package/dist/domains/seo/utils/schema-generators/index.d.ts +7 -0
- package/dist/domains/seo/utils/schema-generators/index.d.ts.map +1 -0
- package/dist/domains/seo/utils/schema-generators/index.js +6 -0
- package/dist/domains/seo/utils/schema-generators/schema.d.ts +135 -0
- package/dist/domains/seo/utils/schema-generators/schema.d.ts.map +1 -0
- package/dist/domains/seo/utils/schema-generators/schema.js +321 -0
- package/dist/domains/seo/utils/validation/index.d.ts +7 -0
- package/dist/domains/seo/utils/validation/index.d.ts.map +1 -0
- package/dist/domains/seo/utils/validation/index.js +6 -0
- package/dist/domains/seo/utils/validation/validators.d.ts +39 -0
- package/dist/domains/seo/utils/validation/validators.d.ts.map +1 -0
- package/dist/domains/seo/utils/validation/validators.js +364 -0
- package/dist/domains/seo/vite/index.d.ts +8 -0
- package/dist/domains/seo/vite/index.d.ts.map +1 -0
- package/dist/domains/seo/vite/index.js +6 -0
- package/dist/domains/seo/vite/plugin.d.ts.map +1 -1
- package/dist/domains/seo/vite/plugin.js +6 -4
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -4
- package/package.json +24 -3
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SEO Validators
|
|
3
|
+
*
|
|
4
|
+
* Validation utilities for SEO configuration and content.
|
|
5
|
+
* Helps catch common SEO issues before they affect search rankings.
|
|
6
|
+
*/
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// URL Validation
|
|
9
|
+
// ============================================================================
|
|
10
|
+
export const isValidUrl = (url) => {
|
|
11
|
+
if (!url)
|
|
12
|
+
return false;
|
|
13
|
+
try {
|
|
14
|
+
const parsed = new URL(url);
|
|
15
|
+
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export const validateUrl = (url, fieldName = "URL") => {
|
|
22
|
+
if (!url) {
|
|
23
|
+
return `${fieldName} is required`;
|
|
24
|
+
}
|
|
25
|
+
if (!isValidUrl(url)) {
|
|
26
|
+
return `${fieldName} must be a valid HTTP/HTTPS URL`;
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
// ============================================================================
|
|
31
|
+
// Content Length Validation
|
|
32
|
+
// ============================================================================
|
|
33
|
+
export const TITLE_MIN_LENGTH = 30;
|
|
34
|
+
export const TITLE_MAX_LENGTH = 60;
|
|
35
|
+
export const DESCRIPTION_MIN_LENGTH = 120;
|
|
36
|
+
export const DESCRIPTION_MAX_LENGTH = 160;
|
|
37
|
+
export const validateTitleLength = (title) => {
|
|
38
|
+
if (!title) {
|
|
39
|
+
return "Title is required";
|
|
40
|
+
}
|
|
41
|
+
if (title.length < TITLE_MIN_LENGTH) {
|
|
42
|
+
return `Title is too short (${title.length} chars). Recommended: ${TITLE_MIN_LENGTH}-${TITLE_MAX_LENGTH} chars`;
|
|
43
|
+
}
|
|
44
|
+
if (title.length > TITLE_MAX_LENGTH) {
|
|
45
|
+
return `Title is too long (${title.length} chars). Recommended: ${TITLE_MIN_LENGTH}-${TITLE_MAX_LENGTH} chars`;
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
};
|
|
49
|
+
export const validateDescriptionLength = (description) => {
|
|
50
|
+
if (!description) {
|
|
51
|
+
return "Description is required";
|
|
52
|
+
}
|
|
53
|
+
if (description.length < DESCRIPTION_MIN_LENGTH) {
|
|
54
|
+
return `Description is too short (${description.length} chars). Recommended: ${DESCRIPTION_MIN_LENGTH}-${DESCRIPTION_MAX_LENGTH} chars`;
|
|
55
|
+
}
|
|
56
|
+
if (description.length > DESCRIPTION_MAX_LENGTH) {
|
|
57
|
+
return `Description is too long (${description.length} chars). Recommended: ${DESCRIPTION_MIN_LENGTH}-${DESCRIPTION_MAX_LENGTH} chars`;
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
};
|
|
61
|
+
// ============================================================================
|
|
62
|
+
// Image Validation for Social Sharing
|
|
63
|
+
// ============================================================================
|
|
64
|
+
export const OG_IMAGE_MIN_WIDTH = 1200;
|
|
65
|
+
export const OG_IMAGE_MIN_HEIGHT = 630;
|
|
66
|
+
export const OG_IMAGE_MAX_SIZE = 8 * 1024 * 1024; // 8MB
|
|
67
|
+
export const validateOpenGraphImage = (imageUrl, width, height, size) => {
|
|
68
|
+
if (!imageUrl) {
|
|
69
|
+
return "Open Graph image URL is required";
|
|
70
|
+
}
|
|
71
|
+
if (!isValidUrl(imageUrl)) {
|
|
72
|
+
return "Open Graph image URL must be valid";
|
|
73
|
+
}
|
|
74
|
+
if (width !== undefined && width < OG_IMAGE_MIN_WIDTH) {
|
|
75
|
+
return `Open Graph image width should be at least ${OG_IMAGE_MIN_WIDTH}px (current: ${width}px)`;
|
|
76
|
+
}
|
|
77
|
+
if (height !== undefined && height < OG_IMAGE_MIN_HEIGHT) {
|
|
78
|
+
return `Open Graph image height should be at least ${OG_IMAGE_MIN_HEIGHT}px (current: ${height}px)`;
|
|
79
|
+
}
|
|
80
|
+
if (size !== undefined && size > OG_IMAGE_MAX_SIZE) {
|
|
81
|
+
return `Open Graph image size should not exceed ${OG_IMAGE_MAX_SIZE / 1024 / 1024}MB`;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
};
|
|
85
|
+
// ============================================================================
|
|
86
|
+
// Hreflang Validation
|
|
87
|
+
// ============================================================================
|
|
88
|
+
export const isValidLanguageCode = (code) => {
|
|
89
|
+
// Check if it's a valid language code (e.g., "en", "en-US", "x-default")
|
|
90
|
+
const langCodeRegex = /^(?:[a-z]{2,3}(?:-[A-Z]{2})?|x-default)$/;
|
|
91
|
+
return langCodeRegex.test(code);
|
|
92
|
+
};
|
|
93
|
+
export const validateHreflangEntry = (entry) => {
|
|
94
|
+
if (!entry.lang) {
|
|
95
|
+
return "Hreflang language code is required";
|
|
96
|
+
}
|
|
97
|
+
if (!isValidLanguageCode(entry.lang)) {
|
|
98
|
+
return `Invalid language code: ${entry.lang}`;
|
|
99
|
+
}
|
|
100
|
+
const urlError = validateUrl(entry.url, "Hreflang URL");
|
|
101
|
+
if (urlError) {
|
|
102
|
+
return urlError;
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
};
|
|
106
|
+
// ============================================================================
|
|
107
|
+
// JSON-LD Validation
|
|
108
|
+
// ============================================================================
|
|
109
|
+
export const validateJsonLd = (jsonLd) => {
|
|
110
|
+
const errors = [];
|
|
111
|
+
// Check @context
|
|
112
|
+
if (!jsonLd["@context"]) {
|
|
113
|
+
errors.push('JSON-LD must have a "@context" property');
|
|
114
|
+
}
|
|
115
|
+
// Check @type
|
|
116
|
+
if (!jsonLd["@type"]) {
|
|
117
|
+
errors.push('JSON-LD must have a "@type" property');
|
|
118
|
+
}
|
|
119
|
+
// Type-specific validation
|
|
120
|
+
const type = jsonLd["@type"];
|
|
121
|
+
switch (type) {
|
|
122
|
+
case "Article":
|
|
123
|
+
case "NewsArticle":
|
|
124
|
+
case "BlogPosting": {
|
|
125
|
+
const article = jsonLd;
|
|
126
|
+
if (!article.headline)
|
|
127
|
+
errors.push("Article must have a headline");
|
|
128
|
+
if (!article.image)
|
|
129
|
+
errors.push("Article must have an image");
|
|
130
|
+
if (!article.datePublished)
|
|
131
|
+
errors.push("Article must have datePublished");
|
|
132
|
+
if (!article.author)
|
|
133
|
+
errors.push("Article must have an author");
|
|
134
|
+
if (!article.publisher)
|
|
135
|
+
errors.push("Article must have a publisher");
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
case "Product": {
|
|
139
|
+
const product = jsonLd;
|
|
140
|
+
if (!product.name)
|
|
141
|
+
errors.push("Product must have a name");
|
|
142
|
+
if (!product.offers)
|
|
143
|
+
errors.push("Product must have offers");
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
case "Organization": {
|
|
147
|
+
const org = jsonLd;
|
|
148
|
+
if (!org.name)
|
|
149
|
+
errors.push("Organization must have a name");
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
case "BreadcrumbList": {
|
|
153
|
+
const breadcrumb = jsonLd;
|
|
154
|
+
if (!breadcrumb.itemListElement || (Array.isArray(breadcrumb.itemListElement) && breadcrumb.itemListElement.length === 0)) {
|
|
155
|
+
errors.push("BreadcrumbList must have itemListElement");
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
case "FAQPage": {
|
|
160
|
+
const faq = jsonLd;
|
|
161
|
+
if (!faq.mainEntity || (Array.isArray(faq.mainEntity) && faq.mainEntity.length === 0)) {
|
|
162
|
+
errors.push("FAQPage must have mainEntity");
|
|
163
|
+
}
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
case "VideoObject": {
|
|
167
|
+
const video = jsonLd;
|
|
168
|
+
if (!video.name)
|
|
169
|
+
errors.push("Video must have a name");
|
|
170
|
+
if (!video.thumbnailUrl)
|
|
171
|
+
errors.push("Video must have thumbnailUrl");
|
|
172
|
+
if (!video.uploadDate)
|
|
173
|
+
errors.push("Video must have uploadDate");
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return errors;
|
|
178
|
+
};
|
|
179
|
+
// ============================================================================
|
|
180
|
+
// Comprehensive SEO Validation
|
|
181
|
+
// ============================================================================
|
|
182
|
+
export const validateSEO = (options) => {
|
|
183
|
+
const errors = [];
|
|
184
|
+
const warnings = [];
|
|
185
|
+
const suggestions = [];
|
|
186
|
+
// Title validation
|
|
187
|
+
if (options.title) {
|
|
188
|
+
const titleError = validateTitleLength(options.title);
|
|
189
|
+
if (titleError) {
|
|
190
|
+
if (options.title === "" || !options.title) {
|
|
191
|
+
errors.push(titleError);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
warnings.push(titleError);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
errors.push("Title is missing");
|
|
200
|
+
}
|
|
201
|
+
// Description validation
|
|
202
|
+
if (options.description) {
|
|
203
|
+
const descError = validateDescriptionLength(options.description);
|
|
204
|
+
if (descError) {
|
|
205
|
+
if (options.description === "" || !options.description) {
|
|
206
|
+
errors.push(descError);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
warnings.push(descError);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
warnings.push("Description is missing");
|
|
215
|
+
}
|
|
216
|
+
// Canonical URL validation
|
|
217
|
+
if (options.canonical) {
|
|
218
|
+
const canonicalError = validateUrl(options.canonical, "Canonical URL");
|
|
219
|
+
if (canonicalError) {
|
|
220
|
+
errors.push(canonicalError);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
suggestions.push("Add a canonical URL to prevent duplicate content issues");
|
|
225
|
+
}
|
|
226
|
+
// Language validation
|
|
227
|
+
if (!options.lang) {
|
|
228
|
+
warnings.push("Language attribute is missing");
|
|
229
|
+
suggestions.push('Add lang attribute (e.g., <html lang="en">)');
|
|
230
|
+
}
|
|
231
|
+
// Open Graph validation
|
|
232
|
+
if (!options.openGraph) {
|
|
233
|
+
suggestions.push("Add Open Graph tags for better social media sharing");
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
if (!options.openGraph.image) {
|
|
237
|
+
suggestions.push("Add Open Graph image for better social media previews");
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
const imageError = validateOpenGraphImage(typeof options.openGraph.image === "string"
|
|
241
|
+
? options.openGraph.image
|
|
242
|
+
: options.openGraph.image[0]?.url || "");
|
|
243
|
+
if (imageError) {
|
|
244
|
+
warnings.push(imageError);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// Twitter Card validation
|
|
249
|
+
if (!options.twitter) {
|
|
250
|
+
suggestions.push("Add Twitter Card tags for better Twitter sharing");
|
|
251
|
+
}
|
|
252
|
+
// Hreflang validation
|
|
253
|
+
if (options.hreflang && options.hreflang.length > 0) {
|
|
254
|
+
options.hreflang.forEach((entry, index) => {
|
|
255
|
+
const error = validateHreflangEntry(entry);
|
|
256
|
+
if (error) {
|
|
257
|
+
errors.push(`Hreflang entry ${index + 1}: ${error}`);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
// Check for x-default
|
|
261
|
+
const hasDefault = options.hreflang.some((entry) => entry.lang === "x-default");
|
|
262
|
+
if (!hasDefault) {
|
|
263
|
+
suggestions.push('Add hreflang="x-default" for language fallback');
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// JSON-LD validation
|
|
267
|
+
if (options.jsonLd && options.jsonLd.length > 0) {
|
|
268
|
+
options.jsonLd.forEach((jsonLd, index) => {
|
|
269
|
+
const jsonLdErrors = validateJsonLd(jsonLd);
|
|
270
|
+
jsonLdErrors.forEach((error) => {
|
|
271
|
+
errors.push(`JSON-LD entry ${index + 1}: ${error}`);
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
suggestions.push("Add JSON-LD structured data for rich snippets in search results");
|
|
277
|
+
}
|
|
278
|
+
// Favicon validation
|
|
279
|
+
if (!options.favicon) {
|
|
280
|
+
suggestions.push("Add a favicon for better brand recognition in browser tabs");
|
|
281
|
+
}
|
|
282
|
+
// Theme color validation
|
|
283
|
+
if (!options.themeColor) {
|
|
284
|
+
suggestions.push("Add a theme color for better mobile browser integration");
|
|
285
|
+
}
|
|
286
|
+
// Performance hints
|
|
287
|
+
if (!options.preconnect || options.preconnect.length === 0) {
|
|
288
|
+
suggestions.push("Add preconnect hints for external resources to improve performance");
|
|
289
|
+
}
|
|
290
|
+
return {
|
|
291
|
+
valid: errors.length === 0,
|
|
292
|
+
errors,
|
|
293
|
+
warnings,
|
|
294
|
+
suggestions,
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
// ============================================================================
|
|
298
|
+
// SEO Audit
|
|
299
|
+
// ============================================================================
|
|
300
|
+
export const auditSEO = (options) => {
|
|
301
|
+
const result = validateSEO(options);
|
|
302
|
+
// Console output in development
|
|
303
|
+
if (typeof console !== "undefined") {
|
|
304
|
+
const style = {
|
|
305
|
+
error: "color: #d32f2f; font-weight: bold;",
|
|
306
|
+
warning: "color: #f57c00; font-weight: bold;",
|
|
307
|
+
success: "color: #388e3c; font-weight: bold;",
|
|
308
|
+
info: "color: #1976d2; font-weight: bold;",
|
|
309
|
+
};
|
|
310
|
+
console.group("%c🔍 SEO Audit Results", style.info);
|
|
311
|
+
if (result.valid) {
|
|
312
|
+
console.log("%c✅ All required SEO elements are present!", style.success);
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
console.log("%c❌ SEO validation failed", style.error);
|
|
316
|
+
}
|
|
317
|
+
if (result.errors.length > 0) {
|
|
318
|
+
console.group("%c🚨 Errors (must fix)", style.error);
|
|
319
|
+
result.errors.forEach((error) => console.error(error));
|
|
320
|
+
console.groupEnd();
|
|
321
|
+
}
|
|
322
|
+
if (result.warnings.length > 0) {
|
|
323
|
+
console.group("%c⚠️ Warnings (should fix)", style.warning);
|
|
324
|
+
result.warnings.forEach((warning) => console.warn(warning));
|
|
325
|
+
console.groupEnd();
|
|
326
|
+
}
|
|
327
|
+
if (result.suggestions.length > 0) {
|
|
328
|
+
console.group("%c💡 Suggestions (nice to have)", style.info);
|
|
329
|
+
result.suggestions.forEach((suggestion) => console.log(suggestion));
|
|
330
|
+
console.groupEnd();
|
|
331
|
+
}
|
|
332
|
+
console.groupEnd();
|
|
333
|
+
}
|
|
334
|
+
return result;
|
|
335
|
+
};
|
|
336
|
+
// ============================================================================
|
|
337
|
+
// Helper Functions
|
|
338
|
+
// ============================================================================
|
|
339
|
+
/**
|
|
340
|
+
* Truncate text to fit within SEO best practices
|
|
341
|
+
*/
|
|
342
|
+
export const truncateForSEO = {
|
|
343
|
+
title: (text) => {
|
|
344
|
+
if (text.length <= TITLE_MAX_LENGTH)
|
|
345
|
+
return text;
|
|
346
|
+
return text.substring(0, TITLE_MAX_LENGTH - 3) + "...";
|
|
347
|
+
},
|
|
348
|
+
description: (text) => {
|
|
349
|
+
if (text.length <= DESCRIPTION_MAX_LENGTH)
|
|
350
|
+
return text;
|
|
351
|
+
return text.substring(0, DESCRIPTION_MAX_LENGTH - 3) + "...";
|
|
352
|
+
},
|
|
353
|
+
};
|
|
354
|
+
/**
|
|
355
|
+
* Generate a slug from text for URL-friendly content
|
|
356
|
+
*/
|
|
357
|
+
export const generateSlug = (text) => {
|
|
358
|
+
return text
|
|
359
|
+
.toLowerCase()
|
|
360
|
+
.trim()
|
|
361
|
+
.replace(/[^\w\s-]/g, "")
|
|
362
|
+
.replace(/[\s_-]+/g, "-")
|
|
363
|
+
.replace(/^-+|-+$/g, "");
|
|
364
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/domains/seo/vite/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3D,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/domains/seo/vite/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;AAQnD,MAAM,WAAW,oBAAoB;IACnC,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,sDAAsD;IACtD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,sBAAsB;IACtB,OAAO,CAAC,EAAE;QACR,sBAAsB;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,8BAA8B;QAC9B,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;QACvF,sCAAsC;QACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,yBAAyB;QACzB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,yBAAyB;IACzB,SAAS,CAAC,EAAE;QACV,sBAAsB;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,uBAAuB;QACvB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAC9C,qBAAqB;QACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAC7B,kBAAkB;QAClB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAC1B,uBAAuB;QACvB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,kBAAkB;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAyHD,eAAO,MAAM,aAAa,GAAI,SAAS,oBAAoB,KAAG,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/domains/seo/vite/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;AAQnD,MAAM,WAAW,oBAAoB;IACnC,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,sDAAsD;IACtD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,sBAAsB;IACtB,OAAO,CAAC,EAAE;QACR,sBAAsB;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,8BAA8B;QAC9B,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;QACvF,sCAAsC;QACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,yBAAyB;QACzB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,yBAAyB;IACzB,SAAS,CAAC,EAAE;QACV,sBAAsB;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,uBAAuB;QACvB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAC9C,qBAAqB;QACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAC7B,kBAAkB;QAClB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAC1B,uBAAuB;QACvB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,kBAAkB;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAyHD,eAAO,MAAM,aAAa,GAAI,SAAS,oBAAoB,KAAG,MAqF7D,CAAC;AAEF,eAAe,aAAa,CAAC;AAM7B;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB;;OAEG;qBACc,MAAM,WAAW,MAAM,EAAE;IAc1C;;OAEG;oBACa,MAAM,WAAW,MAAM,EAAE;IAczC;;OAEG;yBACkB,MAAM,WAAW,MAAM,EAAE;CAc/C,CAAC"}
|
|
@@ -87,7 +87,7 @@ const discoverRoutesFromBuild = (outDir) => {
|
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
|
-
catch
|
|
90
|
+
catch {
|
|
91
91
|
// Directory doesn't exist or isn't accessible yet
|
|
92
92
|
}
|
|
93
93
|
};
|
|
@@ -101,16 +101,18 @@ export const viteSEOPlugin = (options) => {
|
|
|
101
101
|
const { siteUrl, routes: manualRoutes = [], discoverRoutes = false, sitemap: sitemapOptions = {}, robotsTxt: robotsOptions = {}, } = options;
|
|
102
102
|
const sitemapFilename = sitemapOptions.filename || "sitemap.xml";
|
|
103
103
|
const robotsFilename = robotsOptions.filename || "robots.txt";
|
|
104
|
+
// Store plugin state
|
|
105
|
+
const pluginState = {};
|
|
104
106
|
return {
|
|
105
107
|
name: "vite-plugin-seo",
|
|
106
108
|
enforce: "post",
|
|
107
109
|
configResolved(config) {
|
|
108
110
|
// Store resolved config for later use
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
pluginState.publicDir = config.publicDir;
|
|
112
|
+
pluginState.outDir = config.build.outDir;
|
|
111
113
|
},
|
|
112
114
|
generateBundle(_input, _bundle) {
|
|
113
|
-
const outDir =
|
|
115
|
+
const outDir = pluginState.outDir || "dist";
|
|
114
116
|
// Collect routes
|
|
115
117
|
let routes = [...manualRoutes];
|
|
116
118
|
if (discoverRoutes) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { SEO } from "./domains/seo/components/SEO.js";
|
|
2
|
+
export { JsonLd } from "./domains/seo/components/JsonLd.js";
|
|
3
|
+
export { useSEO } from "./domains/seo/hooks/useSEO.js";
|
|
4
|
+
export { useJsonLd } from "./domains/seo/hooks/useJsonLd.js";
|
|
5
|
+
export { initSEO } from "./domains/seo/core/init.js";
|
|
6
|
+
export { updateSEO, clearSEO, getCurrentSEOState } from "./domains/seo/utils/dom.js";
|
|
7
|
+
export { generateArticleSchema, generateProductSchema, generateOrganizationSchema, generateLocalBusinessSchema, generateBreadcrumbSchema, generateFAQSchema, generateWebSiteSchema, generatePersonSchema, generateVideoSchema, } from "./domains/seo/utils/schema-generators/schema.js";
|
|
8
|
+
export { validateSEO, auditSEO, isValidUrl, validateUrl, validateTitleLength, validateDescriptionLength, validateOpenGraphImage, validateHreflangEntry, truncateForSEO, generateSlug, } from "./domains/seo/utils/validation/validators.js";
|
|
9
|
+
export { renderSEO, generateHead, extractSEOData, hydrateSEO, renderAsHelmet, } from "./domains/seo/ssr/renderer.js";
|
|
10
|
+
export { serializeSEO, deserializeSEO, serializeSEOToBase64, deserializeSEOFromBase64, compressSEO, serializeSEOToQueryString, deserializeSEOFromQueryString, safeDeserializeSEO, } from "./domains/seo/ssr/serializer.js";
|
|
11
|
+
export { viteSEOPlugin, quickSEOSetup, } from "./domains/seo/vite/plugin.js";
|
|
12
|
+
export type { MetaTag, LinkTag, ScriptTag, SEOptions, SEOConfig, RobotsMeta, RobotsDirective, HreflangEntry, PreloadHint, PreconnectOrigin, DnsPrefetchDomain, ArticleMeta, ProductMeta, BreadcrumbItem, OpenGraphImage, SEOValidationResult, } from "./domains/seo/types/index.js";
|
|
13
|
+
export type { JsonLdTypes, ArticleJsonLd, ProductJsonLd, OrganizationJsonLd, LocalBusinessJsonLd, BreadcrumbJsonLd, FAQJsonLd, WebSiteJsonLd, PersonJsonLd, VideoJsonLd, SchemaType, SchemaGeneratorOptions, } from "./domains/seo/types/schema.js";
|
|
2
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAGrD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,2BAA2B,EAC3B,wBAAwB,EACxB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACL,WAAW,EACX,QAAQ,EACR,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,yBAAyB,EACzB,sBAAsB,EACtB,qBAAqB,EACrB,cAAc,EACd,YAAY,GACb,MAAM,8CAA8C,CAAC;AAGtD,OAAO,EACL,SAAS,EACT,YAAY,EACZ,cAAc,EACd,UAAU,EACV,cAAc,GACf,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,wBAAwB,EACxB,WAAW,EACX,yBAAyB,EACzB,6BAA6B,EAC7B,kBAAkB,GACnB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACL,aAAa,EACb,aAAa,GACd,MAAM,8BAA8B,CAAC;AAGtC,YAAY,EAEV,OAAO,EACP,OAAO,EACP,SAAS,EACT,SAAS,EACT,SAAS,EAGT,UAAU,EACV,eAAe,EAGf,aAAa,EAGb,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EAGjB,WAAW,EACX,WAAW,EACX,cAAc,EAGd,cAAc,EAGd,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AAEtC,YAAY,EAEV,WAAW,EACX,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,YAAY,EACZ,WAAW,EACX,UAAU,EACV,sBAAsB,GACvB,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
// ============================================================================
|
|
2
|
-
// Main Package
|
|
3
|
-
//
|
|
2
|
+
// Main Package Entry Point
|
|
3
|
+
// Domain-Driven Design structure
|
|
4
4
|
// ============================================================================
|
|
5
|
-
//
|
|
6
|
-
export
|
|
5
|
+
// Core SEO functionality
|
|
6
|
+
export { SEO } from "./domains/seo/components/SEO.js";
|
|
7
|
+
export { JsonLd } from "./domains/seo/components/JsonLd.js";
|
|
8
|
+
export { useSEO } from "./domains/seo/hooks/useSEO.js";
|
|
9
|
+
export { useJsonLd } from "./domains/seo/hooks/useJsonLd.js";
|
|
10
|
+
export { initSEO } from "./domains/seo/core/init.js";
|
|
11
|
+
// Utils
|
|
12
|
+
export { updateSEO, clearSEO, getCurrentSEOState } from "./domains/seo/utils/dom.js";
|
|
13
|
+
export { generateArticleSchema, generateProductSchema, generateOrganizationSchema, generateLocalBusinessSchema, generateBreadcrumbSchema, generateFAQSchema, generateWebSiteSchema, generatePersonSchema, generateVideoSchema, } from "./domains/seo/utils/schema-generators/schema.js";
|
|
14
|
+
export { validateSEO, auditSEO, isValidUrl, validateUrl, validateTitleLength, validateDescriptionLength, validateOpenGraphImage, validateHreflangEntry, truncateForSEO, generateSlug, } from "./domains/seo/utils/validation/validators.js";
|
|
15
|
+
// SSR
|
|
16
|
+
export { renderSEO, generateHead, extractSEOData, hydrateSEO, renderAsHelmet, } from "./domains/seo/ssr/renderer.js";
|
|
17
|
+
export { serializeSEO, deserializeSEO, serializeSEOToBase64, deserializeSEOFromBase64, compressSEO, serializeSEOToQueryString, deserializeSEOFromQueryString, safeDeserializeSEO, } from "./domains/seo/ssr/serializer.js";
|
|
18
|
+
// Vite Plugin
|
|
19
|
+
export { viteSEOPlugin, quickSEOSetup, } from "./domains/seo/vite/plugin.js";
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/web-seo",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "Comprehensive SEO solution for React Vite applications with structured data, performance hints, and build-time optimization",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
8
9
|
"scripts": {
|
|
9
10
|
"build": "tsc",
|
|
10
11
|
"lint": "eslint .",
|
|
@@ -12,8 +13,28 @@
|
|
|
12
13
|
"prepublishOnly": "npm run build"
|
|
13
14
|
},
|
|
14
15
|
"exports": {
|
|
15
|
-
".":
|
|
16
|
-
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json",
|
|
22
|
+
"./components": {
|
|
23
|
+
"types": "./dist/domains/seo/components/index.d.ts",
|
|
24
|
+
"import": "./dist/domains/seo/components/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./hooks": {
|
|
27
|
+
"types": "./dist/domains/seo/hooks/index.d.ts",
|
|
28
|
+
"import": "./dist/domains/seo/hooks/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./utils": {
|
|
31
|
+
"types": "./dist/domains/seo/utils/index.d.ts",
|
|
32
|
+
"import": "./dist/domains/seo/utils/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./vite": {
|
|
35
|
+
"types": "./dist/domains/seo/vite/index.d.ts",
|
|
36
|
+
"import": "./dist/domains/seo/vite/index.js"
|
|
37
|
+
}
|
|
17
38
|
},
|
|
18
39
|
"files": [
|
|
19
40
|
"dist",
|