@umituz/web-seo 2.0.21 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/domains/seo/components/JsonLd.d.ts +7 -6
  2. package/dist/domains/seo/components/JsonLd.js +26 -77
  3. package/dist/domains/seo/components/SEO.d.ts +7 -0
  4. package/dist/domains/seo/components/SEO.js +10 -33
  5. package/dist/domains/seo/core/constants.d.ts +15 -0
  6. package/dist/domains/seo/core/constants.js +15 -0
  7. package/dist/domains/seo/core/deep-equal.d.ts +8 -0
  8. package/dist/domains/seo/core/deep-equal.js +28 -0
  9. package/dist/domains/seo/core/dom-queue.d.ts +10 -0
  10. package/dist/domains/seo/core/dom-queue.js +37 -0
  11. package/dist/domains/seo/core/escape.d.ts +12 -0
  12. package/dist/domains/seo/core/escape.js +41 -0
  13. package/dist/domains/seo/core/hash.d.ts +9 -0
  14. package/dist/domains/seo/core/hash.js +29 -0
  15. package/dist/domains/seo/core/init.d.ts +15 -2
  16. package/dist/domains/seo/core/init.js +38 -18
  17. package/dist/domains/seo/core/seo-strategies.d.ts +29 -0
  18. package/dist/domains/seo/core/seo-strategies.js +694 -0
  19. package/dist/domains/seo/core/seo-strategy.d.ts +37 -0
  20. package/dist/domains/seo/core/seo-strategy.js +14 -0
  21. package/dist/domains/seo/hooks/useJsonLd.d.ts +6 -7
  22. package/dist/domains/seo/hooks/useJsonLd.js +27 -61
  23. package/dist/domains/seo/hooks/useSEO.d.ts +6 -0
  24. package/dist/domains/seo/hooks/useSEO.js +7 -29
  25. package/dist/domains/seo/ssr/helmet.d.ts +25 -0
  26. package/dist/domains/seo/ssr/helmet.js +23 -0
  27. package/dist/domains/seo/ssr/index.d.ts +10 -0
  28. package/dist/domains/seo/ssr/index.js +8 -0
  29. package/dist/domains/seo/ssr/renderer.d.ts +11 -36
  30. package/dist/domains/seo/ssr/renderer.js +51 -285
  31. package/dist/domains/seo/ssr/serializer.d.ts +5 -60
  32. package/dist/domains/seo/ssr/serializer.js +26 -166
  33. package/dist/domains/seo/types/index.d.ts +0 -4
  34. package/dist/domains/seo/types/schema.d.ts +22 -1
  35. package/dist/domains/seo/utils/dom/dom-context.d.ts +13 -0
  36. package/dist/domains/seo/utils/dom/dom-context.js +62 -0
  37. package/dist/domains/seo/utils/dom/dom-mutator.d.ts +31 -0
  38. package/dist/domains/seo/utils/dom/dom-mutator.js +89 -0
  39. package/dist/domains/seo/utils/dom/index.d.ts +1 -0
  40. package/dist/domains/seo/utils/dom/index.js +1 -0
  41. package/dist/domains/seo/utils/index.d.ts +3 -4
  42. package/dist/domains/seo/utils/index.js +3 -5
  43. package/dist/domains/seo/utils/schema-generators/base.d.ts +25 -0
  44. package/dist/domains/seo/utils/schema-generators/base.js +50 -0
  45. package/dist/domains/seo/utils/schema-generators/factory.d.ts +27 -0
  46. package/dist/domains/seo/utils/schema-generators/factory.js +49 -0
  47. package/dist/domains/seo/utils/schema-generators/generators/article.d.ts +4 -0
  48. package/dist/domains/seo/utils/schema-generators/generators/article.js +39 -0
  49. package/dist/domains/seo/utils/schema-generators/generators/breadcrumb.d.ts +6 -0
  50. package/dist/domains/seo/utils/schema-generators/generators/breadcrumb.js +18 -0
  51. package/dist/domains/seo/utils/schema-generators/generators/course.d.ts +3 -0
  52. package/dist/domains/seo/utils/schema-generators/generators/course.js +70 -0
  53. package/dist/domains/seo/utils/schema-generators/generators/faq.d.ts +3 -0
  54. package/dist/domains/seo/utils/schema-generators/generators/faq.js +21 -0
  55. package/dist/domains/seo/utils/schema-generators/generators/local-business.d.ts +3 -0
  56. package/dist/domains/seo/utils/schema-generators/generators/local-business.js +45 -0
  57. package/dist/domains/seo/utils/schema-generators/generators/organization.d.ts +3 -0
  58. package/dist/domains/seo/utils/schema-generators/generators/organization.js +25 -0
  59. package/dist/domains/seo/utils/schema-generators/generators/person.d.ts +3 -0
  60. package/dist/domains/seo/utils/schema-generators/generators/person.js +27 -0
  61. package/dist/domains/seo/utils/schema-generators/generators/product.d.ts +3 -0
  62. package/dist/domains/seo/utils/schema-generators/generators/product.js +40 -0
  63. package/dist/domains/seo/utils/schema-generators/generators/video.d.ts +3 -0
  64. package/dist/domains/seo/utils/schema-generators/generators/video.js +23 -0
  65. package/dist/domains/seo/utils/schema-generators/generators/website.d.ts +3 -0
  66. package/dist/domains/seo/utils/schema-generators/generators/website.js +30 -0
  67. package/dist/domains/seo/utils/schema-generators/index.d.ts +15 -2
  68. package/dist/domains/seo/utils/schema-generators/index.js +13 -2
  69. package/dist/domains/seo/utils/schema-generators/types.d.ts +142 -0
  70. package/dist/domains/seo/utils/schema-generators/types.js +5 -0
  71. package/dist/domains/seo/utils/validation/hreflang-validator.d.ts +7 -0
  72. package/dist/domains/seo/utils/validation/hreflang-validator.js +13 -0
  73. package/dist/domains/seo/utils/validation/image-validator.d.ts +7 -0
  74. package/dist/domains/seo/utils/validation/image-validator.js +24 -0
  75. package/dist/domains/seo/utils/validation/index.d.ts +10 -2
  76. package/dist/domains/seo/utils/validation/index.js +10 -2
  77. package/dist/domains/seo/utils/validation/jsonld-validator.d.ts +9 -0
  78. package/dist/domains/seo/utils/validation/jsonld-validator.js +74 -0
  79. package/dist/domains/seo/utils/validation/language-code.d.ts +7 -0
  80. package/dist/domains/seo/utils/validation/language-code.js +8 -0
  81. package/dist/domains/seo/utils/validation/length-validator.d.ts +10 -0
  82. package/dist/domains/seo/utils/validation/length-validator.js +40 -0
  83. package/dist/domains/seo/utils/validation/seo-auditor.d.ts +17 -0
  84. package/dist/domains/seo/utils/validation/seo-auditor.js +144 -0
  85. package/dist/domains/seo/utils/validation/text-helpers.d.ts +7 -0
  86. package/dist/domains/seo/utils/validation/text-helpers.js +12 -0
  87. package/dist/domains/seo/utils/validation/url-validator.d.ts +8 -0
  88. package/dist/domains/seo/utils/validation/url-validator.js +26 -0
  89. package/dist/domains/seo/vite/index.d.ts +6 -4
  90. package/dist/domains/seo/vite/index.js +5 -3
  91. package/dist/domains/seo/vite/plugin.d.ts +3 -55
  92. package/dist/domains/seo/vite/plugin.js +28 -186
  93. package/dist/domains/seo/vite/presets.d.ts +14 -0
  94. package/dist/domains/seo/vite/presets.js +33 -0
  95. package/dist/domains/seo/vite/robots-generator.d.ts +9 -0
  96. package/dist/domains/seo/vite/robots-generator.js +36 -0
  97. package/dist/domains/seo/vite/sitemap-generator.d.ts +15 -0
  98. package/dist/domains/seo/vite/sitemap-generator.js +56 -0
  99. package/dist/domains/seo/vite/types.d.ts +29 -0
  100. package/dist/domains/seo/vite/types.js +4 -0
  101. package/dist/index.d.ts +8 -7
  102. package/dist/index.js +7 -6
  103. package/package.json +1 -1
@@ -0,0 +1,25 @@
1
+ import { createBuilder, withContext } from "../base.js";
2
+ export const generateOrganizationSchema = createBuilder((input, ctx) => {
3
+ ctx.required(input.name, "name");
4
+ ctx.set(withContext("Organization"));
5
+ ctx.set({
6
+ name: input.name,
7
+ description: input.description,
8
+ url: input.url,
9
+ logo: input.logo,
10
+ sameAs: input.sameAs,
11
+ });
12
+ if (input.contactPoint) {
13
+ ctx.set({
14
+ contactPoint: input.contactPoint.map((cp) => ({
15
+ "@type": "ContactPoint",
16
+ telephone: cp.telephone,
17
+ contactType: cp.contactType,
18
+ email: cp.email,
19
+ })),
20
+ });
21
+ }
22
+ if (input.address) {
23
+ ctx.set({ address: { "@type": "PostalAddress", ...input.address } });
24
+ }
25
+ });
@@ -0,0 +1,3 @@
1
+ import type { PersonJsonLd } from "../../../types/schema.js";
2
+ import type { PersonSchemaInput } from "../types.js";
3
+ export declare const generatePersonSchema: (input: PersonSchemaInput, options?: import("../../../types/schema.js").SchemaGeneratorOptions) => PersonJsonLd;
@@ -0,0 +1,27 @@
1
+ import { createBuilder, withContext } from "../base.js";
2
+ export const generatePersonSchema = createBuilder((input, ctx) => {
3
+ ctx.required(input.name, "name");
4
+ ctx.set(withContext("Person"));
5
+ ctx.set({
6
+ name: input.name,
7
+ givenName: input.givenName,
8
+ familyName: input.familyName,
9
+ jobTitle: input.jobTitle,
10
+ description: input.description,
11
+ image: input.image,
12
+ url: input.url,
13
+ sameAs: input.sameAs,
14
+ email: input.email,
15
+ telephone: input.telephone,
16
+ });
17
+ if (input.worksFor) {
18
+ ctx.set({
19
+ worksFor: {
20
+ "@context": "https://schema.org",
21
+ "@type": "Organization",
22
+ name: input.worksFor.name,
23
+ url: input.worksFor.url,
24
+ },
25
+ });
26
+ }
27
+ });
@@ -0,0 +1,3 @@
1
+ import type { ProductJsonLd } from "../../../types/schema.js";
2
+ import type { ProductSchemaInput } from "../types.js";
3
+ export declare const generateProductSchema: (input: ProductSchemaInput, options?: import("../../../types/schema.js").SchemaGeneratorOptions) => ProductJsonLd;
@@ -0,0 +1,40 @@
1
+ import { createBuilder, withContext } from "../base.js";
2
+ export const generateProductSchema = createBuilder((input, ctx) => {
3
+ ctx.required(input.name, "name");
4
+ ctx.required(input.image, "image");
5
+ ctx.required(input.price, "price");
6
+ ctx.required(input.priceCurrency, "priceCurrency");
7
+ ctx.set(withContext("Product"));
8
+ ctx.set({
9
+ name: input.name,
10
+ description: input.description,
11
+ image: input.image,
12
+ offers: {
13
+ "@type": "Offer",
14
+ price: input.price.toString(),
15
+ priceCurrency: input.priceCurrency,
16
+ availability: input.availability
17
+ ? `https://schema.org/${input.availability}`
18
+ : undefined,
19
+ url: input.url,
20
+ },
21
+ });
22
+ if (input.brandName) {
23
+ ctx.set({ brand: { "@type": "Brand", name: input.brandName } });
24
+ }
25
+ if (input.sku)
26
+ ctx.set({ sku: input.sku });
27
+ if (input.gtin)
28
+ ctx.set({ gtin: input.gtin });
29
+ if (input.aggregateRating) {
30
+ ctx.set({
31
+ aggregateRating: {
32
+ "@type": "AggregateRating",
33
+ ratingValue: input.aggregateRating.ratingValue,
34
+ reviewCount: input.aggregateRating.reviewCount,
35
+ bestRating: 5,
36
+ worstRating: 1,
37
+ },
38
+ });
39
+ }
40
+ });
@@ -0,0 +1,3 @@
1
+ import type { VideoJsonLd } from "../../../types/schema.js";
2
+ import type { VideoSchemaInput } from "../types.js";
3
+ export declare const generateVideoSchema: (input: VideoSchemaInput, options?: import("../../../types/schema.js").SchemaGeneratorOptions) => VideoJsonLd;
@@ -0,0 +1,23 @@
1
+ import { createBuilder, withContext } from "../base.js";
2
+ export const generateVideoSchema = createBuilder((input, ctx) => {
3
+ ctx.required(input.name, "name");
4
+ ctx.required(input.thumbnailUrl, "thumbnailUrl");
5
+ ctx.required(input.uploadDate, "uploadDate");
6
+ ctx.set(withContext("VideoObject"));
7
+ ctx.set({
8
+ name: input.name,
9
+ description: input.description,
10
+ thumbnailUrl: input.thumbnailUrl,
11
+ uploadDate: input.uploadDate,
12
+ duration: input.duration,
13
+ });
14
+ if (input.viewCount) {
15
+ ctx.set({
16
+ interactionStatistic: {
17
+ "@type": "InteractionCounter",
18
+ interactionType: { "@type": "WatchAction" },
19
+ userInteractionCount: input.viewCount,
20
+ },
21
+ });
22
+ }
23
+ });
@@ -0,0 +1,3 @@
1
+ import type { WebSiteJsonLd } from "../../../types/schema.js";
2
+ import type { WebSiteSchemaInput } from "../types.js";
3
+ export declare const generateWebSiteSchema: (input: WebSiteSchemaInput, options?: import("../../../types/schema.js").SchemaGeneratorOptions) => WebSiteJsonLd;
@@ -0,0 +1,30 @@
1
+ import { createBuilder, withContext } from "../base.js";
2
+ export const generateWebSiteSchema = createBuilder((input, ctx) => {
3
+ ctx.required(input.name, "name");
4
+ ctx.required(input.url, "url");
5
+ ctx.set(withContext("WebSite"));
6
+ ctx.set({
7
+ name: input.name,
8
+ url: input.url,
9
+ description: input.description,
10
+ });
11
+ if (input.searchTarget) {
12
+ ctx.set({
13
+ potentialAction: {
14
+ "@type": "SearchAction",
15
+ target: input.searchTarget,
16
+ "query-input": input.searchQueryParam ?? "required name=search_term_string",
17
+ },
18
+ });
19
+ }
20
+ if (input.publisher) {
21
+ ctx.set({
22
+ publisher: {
23
+ "@context": "https://schema.org",
24
+ "@type": "Organization",
25
+ name: input.publisher.name,
26
+ logo: input.publisher.logo,
27
+ },
28
+ });
29
+ }
30
+ });
@@ -1,6 +1,19 @@
1
1
  /**
2
2
  * Schema.org Generators
3
3
  *
4
- * Helper functions to generate valid Schema.org structured data
4
+ * Public surface for structured-data generation. One file per generator
5
+ * (see ./generators/*) plus a factory for dynamic dispatch.
5
6
  */
6
- export { generateArticleSchema, generateProductSchema, generateOrganizationSchema, generateLocalBusinessSchema, generateBreadcrumbSchema, generateFAQSchema, generateWebSiteSchema, generatePersonSchema, generateVideoSchema, } from "./schema.js";
7
+ export { generateArticleSchema } from "./generators/article.js";
8
+ export { generateProductSchema } from "./generators/product.js";
9
+ export { generateOrganizationSchema } from "./generators/organization.js";
10
+ export { generateLocalBusinessSchema } from "./generators/local-business.js";
11
+ export { generateBreadcrumbSchema } from "./generators/breadcrumb.js";
12
+ export { generateFAQSchema } from "./generators/faq.js";
13
+ export { generateWebSiteSchema } from "./generators/website.js";
14
+ export { generatePersonSchema } from "./generators/person.js";
15
+ export { generateVideoSchema } from "./generators/video.js";
16
+ export { generateCourseSchema } from "./generators/course.js";
17
+ export { schemaFactory } from "./factory.js";
18
+ export type { SchemaKind } from "./factory.js";
19
+ export type { ArticleSchemaInput, ProductSchemaInput, OrganizationSchemaInput, LocalBusinessSchemaInput, FAQItemInput, WebSiteSchemaInput, PersonSchemaInput, VideoSchemaInput, CourseSchemaInput, CourseInstanceInput, ContactPointInput, PostalAddressInput, } from "./types.js";
@@ -1,6 +1,17 @@
1
1
  /**
2
2
  * Schema.org Generators
3
3
  *
4
- * Helper functions to generate valid Schema.org structured data
4
+ * Public surface for structured-data generation. One file per generator
5
+ * (see ./generators/*) plus a factory for dynamic dispatch.
5
6
  */
6
- export { generateArticleSchema, generateProductSchema, generateOrganizationSchema, generateLocalBusinessSchema, generateBreadcrumbSchema, generateFAQSchema, generateWebSiteSchema, generatePersonSchema, generateVideoSchema, } from "./schema.js";
7
+ export { generateArticleSchema } from "./generators/article.js";
8
+ export { generateProductSchema } from "./generators/product.js";
9
+ export { generateOrganizationSchema } from "./generators/organization.js";
10
+ export { generateLocalBusinessSchema } from "./generators/local-business.js";
11
+ export { generateBreadcrumbSchema } from "./generators/breadcrumb.js";
12
+ export { generateFAQSchema } from "./generators/faq.js";
13
+ export { generateWebSiteSchema } from "./generators/website.js";
14
+ export { generatePersonSchema } from "./generators/person.js";
15
+ export { generateVideoSchema } from "./generators/video.js";
16
+ export { generateCourseSchema } from "./generators/course.js";
17
+ export { schemaFactory } from "./factory.js";
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Schema generator input types.
3
+ * Kept in one place so consumers can import just the shapes they need.
4
+ */
5
+ export interface ArticleSchemaInput {
6
+ headline: string;
7
+ description?: string;
8
+ image: string | string[];
9
+ datePublished: string;
10
+ dateModified?: string;
11
+ authorName: string;
12
+ authorUrl?: string;
13
+ authorType?: "Person" | "Organization";
14
+ publisherName: string;
15
+ publisherLogo: string;
16
+ publisherUrl?: string;
17
+ url?: string;
18
+ articleSection?: string;
19
+ wordCount?: number;
20
+ keywords?: string | string[];
21
+ inLanguage?: string;
22
+ type?: "Article" | "NewsArticle" | "BlogPosting";
23
+ }
24
+ export interface ProductSchemaInput {
25
+ name: string;
26
+ description?: string;
27
+ image: string | string[];
28
+ price: number;
29
+ priceCurrency: string;
30
+ availability?: "InStock" | "OutOfStock" | "PreOrder";
31
+ url?: string;
32
+ brandName?: string;
33
+ sku?: string;
34
+ gtin?: string;
35
+ aggregateRating?: {
36
+ ratingValue: number;
37
+ reviewCount: number;
38
+ };
39
+ }
40
+ export interface ContactPointInput {
41
+ telephone: string;
42
+ contactType: string;
43
+ email?: string;
44
+ }
45
+ export interface PostalAddressInput {
46
+ streetAddress: string;
47
+ addressLocality: string;
48
+ addressRegion: string;
49
+ postalCode: string;
50
+ addressCountry: string;
51
+ }
52
+ export interface OrganizationSchemaInput {
53
+ name: string;
54
+ description?: string;
55
+ url?: string;
56
+ logo?: string;
57
+ sameAs?: string[];
58
+ contactPoint?: ContactPointInput[];
59
+ address?: PostalAddressInput;
60
+ }
61
+ export interface LocalBusinessSchemaInput extends OrganizationSchemaInput {
62
+ address: PostalAddressInput;
63
+ geo?: {
64
+ latitude: number;
65
+ longitude: number;
66
+ };
67
+ openingHours?: Array<{
68
+ dayOfWeek: string | string[];
69
+ opens: string;
70
+ closes: string;
71
+ }>;
72
+ priceRange?: string;
73
+ type?: "LocalBusiness" | "Restaurant" | "Store" | "Dentist" | "Hospital";
74
+ }
75
+ export interface FAQItemInput {
76
+ question: string;
77
+ answer: string;
78
+ }
79
+ export interface WebSiteSchemaInput {
80
+ name: string;
81
+ url: string;
82
+ description?: string;
83
+ searchTarget?: string;
84
+ searchQueryParam?: string;
85
+ publisher?: {
86
+ name: string;
87
+ logo?: string;
88
+ };
89
+ }
90
+ export interface PersonSchemaInput {
91
+ name: string;
92
+ givenName?: string;
93
+ familyName?: string;
94
+ jobTitle?: string;
95
+ description?: string;
96
+ image?: string;
97
+ url?: string;
98
+ sameAs?: string[];
99
+ email?: string;
100
+ telephone?: string;
101
+ worksFor?: {
102
+ name: string;
103
+ url?: string;
104
+ };
105
+ }
106
+ export interface VideoSchemaInput {
107
+ name: string;
108
+ description?: string;
109
+ thumbnailUrl: string;
110
+ uploadDate: string;
111
+ duration?: string;
112
+ embedUrl?: string;
113
+ viewCount?: number;
114
+ }
115
+ export interface CourseInstanceInput {
116
+ courseMode?: "online" | "onsite" | "blended" | string;
117
+ courseWorkload?: string;
118
+ instructorName?: string;
119
+ instructorUrl?: string;
120
+ inLanguage?: string;
121
+ startDate?: string;
122
+ endDate?: string;
123
+ }
124
+ export interface CourseSchemaInput {
125
+ name: string;
126
+ description: string;
127
+ providerName: string;
128
+ providerUrl?: string;
129
+ image?: string | string[];
130
+ url?: string;
131
+ courseCode?: string;
132
+ educationalLevel?: string;
133
+ inLanguage?: string;
134
+ price?: number;
135
+ priceCurrency?: string;
136
+ teaches?: string | string[];
137
+ aggregateRating?: {
138
+ ratingValue: number;
139
+ reviewCount: number;
140
+ };
141
+ instances?: CourseInstanceInput[];
142
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Schema generator input types.
3
+ * Kept in one place so consumers can import just the shapes they need.
4
+ */
5
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Hreflang validation.
3
+ */
4
+ export declare const validateHreflangEntry: (entry: {
5
+ lang: string;
6
+ url: string;
7
+ }) => string | null;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Hreflang validation.
3
+ */
4
+ import { isValidLanguageCode } from "./language-code.js";
5
+ import { validateUrl } from "./url-validator.js";
6
+ export const validateHreflangEntry = (entry) => {
7
+ if (!entry.lang)
8
+ return "Hreflang language code is required";
9
+ if (!isValidLanguageCode(entry.lang)) {
10
+ return `Invalid language code: ${entry.lang}`;
11
+ }
12
+ return validateUrl(entry.url, "Hreflang URL");
13
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Open Graph image validation.
3
+ *
4
+ * All four parameters are optional so callers can progressively validate
5
+ * as soon as they know each value.
6
+ */
7
+ export declare const validateOpenGraphImage: (imageUrl: string, width?: number, height?: number, size?: number) => string | null;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Open Graph image validation.
3
+ *
4
+ * All four parameters are optional so callers can progressively validate
5
+ * as soon as they know each value.
6
+ */
7
+ import { OG_IMAGE_MAX_SIZE, OG_IMAGE_MIN_HEIGHT, OG_IMAGE_MIN_WIDTH, } from "../../core/constants.js";
8
+ import { isValidUrl } from "./url-validator.js";
9
+ export const validateOpenGraphImage = (imageUrl, width, height, size) => {
10
+ if (!imageUrl)
11
+ return "Open Graph image URL is required";
12
+ if (!isValidUrl(imageUrl))
13
+ return "Open Graph image URL must be valid";
14
+ if (width !== undefined && width < OG_IMAGE_MIN_WIDTH) {
15
+ return `Open Graph image width should be at least ${OG_IMAGE_MIN_WIDTH}px (current: ${width}px)`;
16
+ }
17
+ if (height !== undefined && height < OG_IMAGE_MIN_HEIGHT) {
18
+ return `Open Graph image height should be at least ${OG_IMAGE_MIN_HEIGHT}px (current: ${height}px)`;
19
+ }
20
+ if (size !== undefined && size > OG_IMAGE_MAX_SIZE) {
21
+ return `Open Graph image size should not exceed ${OG_IMAGE_MAX_SIZE / 1024 / 1024}MB`;
22
+ }
23
+ return null;
24
+ };
@@ -1,6 +1,14 @@
1
1
  /**
2
2
  * SEO Validators
3
3
  *
4
- * Validation utilities for SEO configuration and content
4
+ * Validation utilities, organized by concern. Each submodule is a small,
5
+ * focused unit so consumers can pull in only what they need.
5
6
  */
6
- export { validateSEO, auditSEO, isValidUrl, validateUrl, validateTitleLength, validateDescriptionLength, validateOpenGraphImage, validateHreflangEntry, truncateForSEO, generateSlug, } from "./validators.js";
7
+ export { isValidUrl, validateUrl } from "./url-validator.js";
8
+ export { isValidLanguageCode } from "./language-code.js";
9
+ export { validateTitleLength, validateDescriptionLength, truncateToTitle, truncateToDescription, } from "./length-validator.js";
10
+ export { validateOpenGraphImage } from "./image-validator.js";
11
+ export { validateHreflangEntry } from "./hreflang-validator.js";
12
+ export { validateJsonLd } from "./jsonld-validator.js";
13
+ export { validateSEO, auditSEO } from "./seo-auditor.js";
14
+ export { generateSlug } from "./text-helpers.js";
@@ -1,6 +1,14 @@
1
1
  /**
2
2
  * SEO Validators
3
3
  *
4
- * Validation utilities for SEO configuration and content
4
+ * Validation utilities, organized by concern. Each submodule is a small,
5
+ * focused unit so consumers can pull in only what they need.
5
6
  */
6
- export { validateSEO, auditSEO, isValidUrl, validateUrl, validateTitleLength, validateDescriptionLength, validateOpenGraphImage, validateHreflangEntry, truncateForSEO, generateSlug, } from "./validators.js";
7
+ export { isValidUrl, validateUrl } from "./url-validator.js";
8
+ export { isValidLanguageCode } from "./language-code.js";
9
+ export { validateTitleLength, validateDescriptionLength, truncateToTitle, truncateToDescription, } from "./length-validator.js";
10
+ export { validateOpenGraphImage } from "./image-validator.js";
11
+ export { validateHreflangEntry } from "./hreflang-validator.js";
12
+ export { validateJsonLd } from "./jsonld-validator.js";
13
+ export { validateSEO, auditSEO } from "./seo-auditor.js";
14
+ export { generateSlug } from "./text-helpers.js";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * JSON-LD payload validation.
3
+ *
4
+ * Each Schema.org type has its own set of required fields. We use a
5
+ * small type-specific validator per `@type` rather than a giant switch
6
+ * to keep each branch easy to extend.
7
+ */
8
+ import type { JsonLdTypes } from "../../types/schema.js";
9
+ export declare const validateJsonLd: (jsonLd: JsonLdTypes) => string[];
@@ -0,0 +1,74 @@
1
+ /**
2
+ * JSON-LD payload validation.
3
+ *
4
+ * Each Schema.org type has its own set of required fields. We use a
5
+ * small type-specific validator per `@type` rather than a giant switch
6
+ * to keep each branch easy to extend.
7
+ */
8
+ const has = (obj, key) => {
9
+ const value = obj[key];
10
+ if (Array.isArray(value))
11
+ return value.length > 0;
12
+ return Boolean(value);
13
+ };
14
+ const articleRules = (jsonLd, errors) => {
15
+ if (!has(jsonLd, "headline"))
16
+ errors.push("Article must have a headline");
17
+ if (!has(jsonLd, "image"))
18
+ errors.push("Article must have an image");
19
+ if (!has(jsonLd, "datePublished"))
20
+ errors.push("Article must have datePublished");
21
+ if (!has(jsonLd, "author"))
22
+ errors.push("Article must have an author");
23
+ if (!has(jsonLd, "publisher"))
24
+ errors.push("Article must have a publisher");
25
+ };
26
+ const productRules = (jsonLd, errors) => {
27
+ if (!has(jsonLd, "name"))
28
+ errors.push("Product must have a name");
29
+ if (!has(jsonLd, "offers"))
30
+ errors.push("Product must have offers");
31
+ };
32
+ const organizationRules = (jsonLd, errors) => {
33
+ if (!has(jsonLd, "name"))
34
+ errors.push("Organization must have a name");
35
+ };
36
+ const breadcrumbRules = (jsonLd, errors) => {
37
+ if (!has(jsonLd, "itemListElement"))
38
+ errors.push("BreadcrumbList must have itemListElement");
39
+ };
40
+ const faqRules = (jsonLd, errors) => {
41
+ if (!has(jsonLd, "mainEntity"))
42
+ errors.push("FAQPage must have mainEntity");
43
+ };
44
+ const videoRules = (jsonLd, errors) => {
45
+ if (!has(jsonLd, "name"))
46
+ errors.push("Video must have a name");
47
+ if (!has(jsonLd, "thumbnailUrl"))
48
+ errors.push("Video must have thumbnailUrl");
49
+ if (!has(jsonLd, "uploadDate"))
50
+ errors.push("Video must have uploadDate");
51
+ };
52
+ const TYPE_RULES = {
53
+ Article: articleRules,
54
+ NewsArticle: articleRules,
55
+ BlogPosting: articleRules,
56
+ Product: productRules,
57
+ Organization: organizationRules,
58
+ BreadcrumbList: breadcrumbRules,
59
+ FAQPage: faqRules,
60
+ VideoObject: videoRules,
61
+ };
62
+ export const validateJsonLd = (jsonLd) => {
63
+ const errors = [];
64
+ const record = jsonLd;
65
+ if (!record["@context"])
66
+ errors.push('JSON-LD must have a "@context" property');
67
+ if (!record["@type"])
68
+ errors.push('JSON-LD must have a "@type" property');
69
+ const type = record["@type"];
70
+ if (typeof type === "string") {
71
+ TYPE_RULES[type]?.(record, errors);
72
+ }
73
+ return errors;
74
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * BCP-47 language code validation.
3
+ *
4
+ * Accepts ISO 639-1/2/3 codes with an optional region (e.g. `en`, `en-US`)
5
+ * and the special `x-default` value used by hreflang.
6
+ */
7
+ export declare const isValidLanguageCode: (code: string) => boolean;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * BCP-47 language code validation.
3
+ *
4
+ * Accepts ISO 639-1/2/3 codes with an optional region (e.g. `en`, `en-US`)
5
+ * and the special `x-default` value used by hreflang.
6
+ */
7
+ const LANG_CODE_REGEX = /^(?:[a-z]{2,3}(?:-[A-Z]{2})?|x-default)$/;
8
+ export const isValidLanguageCode = (code) => LANG_CODE_REGEX.test(code);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Title and description length validation + truncation helpers.
3
+ *
4
+ * Bounds are exported from `core/constants` so all SEO concerns agree on
5
+ * the recommended ranges.
6
+ */
7
+ export declare const validateTitleLength: (title: string) => string | null;
8
+ export declare const validateDescriptionLength: (description: string) => string | null;
9
+ export declare const truncateToTitle: (text: string) => string;
10
+ export declare const truncateToDescription: (text: string) => string;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Title and description length validation + truncation helpers.
3
+ *
4
+ * Bounds are exported from `core/constants` so all SEO concerns agree on
5
+ * the recommended ranges.
6
+ */
7
+ import { DESCRIPTION_MAX_LENGTH, DESCRIPTION_MIN_LENGTH, TITLE_MAX_LENGTH, TITLE_MIN_LENGTH, } from "../../core/constants.js";
8
+ const ELLIPSIS = "...";
9
+ export const validateTitleLength = (title) => {
10
+ if (!title)
11
+ return "Title is required";
12
+ if (title.length < TITLE_MIN_LENGTH) {
13
+ return `Title is too short (${title.length} chars). Recommended: ${TITLE_MIN_LENGTH}-${TITLE_MAX_LENGTH} chars`;
14
+ }
15
+ if (title.length > TITLE_MAX_LENGTH) {
16
+ return `Title is too long (${title.length} chars). Recommended: ${TITLE_MIN_LENGTH}-${TITLE_MAX_LENGTH} chars`;
17
+ }
18
+ return null;
19
+ };
20
+ export const validateDescriptionLength = (description) => {
21
+ if (!description)
22
+ return "Description is required";
23
+ if (description.length < DESCRIPTION_MIN_LENGTH) {
24
+ return `Description is too short (${description.length} chars). Recommended: ${DESCRIPTION_MIN_LENGTH}-${DESCRIPTION_MAX_LENGTH} chars`;
25
+ }
26
+ if (description.length > DESCRIPTION_MAX_LENGTH) {
27
+ return `Description is too long (${description.length} chars). Recommended: ${DESCRIPTION_MIN_LENGTH}-${DESCRIPTION_MAX_LENGTH} chars`;
28
+ }
29
+ return null;
30
+ };
31
+ export const truncateToTitle = (text) => {
32
+ if (text.length <= TITLE_MAX_LENGTH)
33
+ return text;
34
+ return text.substring(0, TITLE_MAX_LENGTH - ELLIPSIS.length) + ELLIPSIS;
35
+ };
36
+ export const truncateToDescription = (text) => {
37
+ if (text.length <= DESCRIPTION_MAX_LENGTH)
38
+ return text;
39
+ return text.substring(0, DESCRIPTION_MAX_LENGTH - ELLIPSIS.length) + ELLIPSIS;
40
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Comprehensive SEO validation and audit.
3
+ *
4
+ * `validateSEO` returns a structured result; `auditSEO` adds a dev-friendly
5
+ * console summary. Neither mutates inputs.
6
+ */
7
+ import type { SEOValidationResult, SEOptions } from "../../types/index.js";
8
+ export declare const validateSEO: (options: SEOptions) => SEOValidationResult;
9
+ /**
10
+ * Validate SEO options and print a human-readable report to the console.
11
+ * Opt-in: pass `enableConsole: true` to actually log.
12
+ *
13
+ * Browser-safe: does not read `process.env` (which is undefined in some
14
+ * browser bundles). Use Vite's `import.meta.env.DEV` or a build-time
15
+ * constant if you want dev-only output.
16
+ */
17
+ export declare const auditSEO: (options: SEOptions, enableConsole?: boolean) => SEOValidationResult;