@umituz/web-seo 1.0.5 → 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.
Files changed (86) hide show
  1. package/README.md +433 -0
  2. package/dist/domains/seo/components/JsonLd.d.ts +17 -0
  3. package/dist/domains/seo/components/JsonLd.d.ts.map +1 -0
  4. package/dist/domains/seo/components/JsonLd.js +52 -0
  5. package/dist/domains/seo/components/SEO.d.ts +4 -0
  6. package/dist/domains/seo/components/SEO.d.ts.map +1 -0
  7. package/dist/domains/seo/components/SEO.js +48 -0
  8. package/dist/domains/seo/components/index.d.ts +8 -0
  9. package/dist/domains/seo/components/index.d.ts.map +1 -0
  10. package/dist/domains/seo/components/index.js +7 -0
  11. package/dist/domains/seo/core/init.d.ts +16 -0
  12. package/dist/domains/seo/core/init.d.ts.map +1 -0
  13. package/dist/domains/seo/core/init.js +34 -0
  14. package/dist/domains/seo/hooks/index.d.ts +8 -0
  15. package/dist/domains/seo/hooks/index.d.ts.map +1 -0
  16. package/dist/domains/seo/hooks/index.js +7 -0
  17. package/dist/domains/seo/hooks/useJsonLd.d.ts +19 -0
  18. package/dist/domains/seo/hooks/useJsonLd.d.ts.map +1 -0
  19. package/dist/domains/seo/hooks/useJsonLd.js +53 -0
  20. package/dist/domains/seo/hooks/useSEO.d.ts +3 -0
  21. package/dist/domains/seo/hooks/useSEO.d.ts.map +1 -0
  22. package/dist/domains/seo/hooks/useSEO.js +47 -0
  23. package/dist/domains/seo/index.d.ts +15 -0
  24. package/dist/domains/seo/index.d.ts.map +1 -0
  25. package/dist/domains/seo/index.js +21 -0
  26. package/dist/domains/seo/ssr/renderer.d.ts +58 -0
  27. package/dist/domains/seo/ssr/renderer.d.ts.map +1 -0
  28. package/dist/domains/seo/ssr/renderer.js +242 -0
  29. package/dist/domains/seo/ssr/serializer.d.ts +71 -0
  30. package/dist/domains/seo/ssr/serializer.d.ts.map +1 -0
  31. package/dist/domains/seo/ssr/serializer.js +175 -0
  32. package/dist/domains/seo/types/index.d.ts +194 -0
  33. package/dist/domains/seo/types/index.d.ts.map +1 -0
  34. package/dist/domains/seo/types/index.js +1 -0
  35. package/dist/domains/seo/types/schema.d.ts +212 -0
  36. package/dist/domains/seo/types/schema.d.ts.map +1 -0
  37. package/dist/domains/seo/types/schema.js +4 -0
  38. package/dist/domains/seo/utils/dom.d.ts +24 -0
  39. package/dist/domains/seo/utils/dom.d.ts.map +1 -0
  40. package/dist/domains/seo/utils/dom.js +224 -0
  41. package/dist/domains/seo/utils/index.d.ts +10 -0
  42. package/dist/domains/seo/utils/index.d.ts.map +1 -0
  43. package/dist/domains/seo/utils/index.js +13 -0
  44. package/dist/domains/seo/utils/meta-tags/advanced.d.ts +31 -0
  45. package/dist/domains/seo/utils/meta-tags/advanced.d.ts.map +1 -0
  46. package/dist/domains/seo/utils/meta-tags/advanced.js +75 -0
  47. package/dist/domains/seo/utils/meta-tags/basic.d.ts +19 -0
  48. package/dist/domains/seo/utils/meta-tags/basic.d.ts.map +1 -0
  49. package/dist/domains/seo/utils/meta-tags/basic.js +93 -0
  50. package/dist/domains/seo/utils/meta-tags/index.d.ts +10 -0
  51. package/dist/domains/seo/utils/meta-tags/index.d.ts.map +1 -0
  52. package/dist/domains/seo/utils/meta-tags/index.js +9 -0
  53. package/dist/domains/seo/utils/meta-tags/performance.d.ts +19 -0
  54. package/dist/domains/seo/utils/meta-tags/performance.d.ts.map +1 -0
  55. package/dist/domains/seo/utils/meta-tags/performance.js +63 -0
  56. package/dist/domains/seo/utils/meta-tags/social.d.ts +15 -0
  57. package/dist/domains/seo/utils/meta-tags/social.d.ts.map +1 -0
  58. package/dist/domains/seo/utils/meta-tags/social.js +132 -0
  59. package/dist/domains/seo/utils/schema-generators/index.d.ts +7 -0
  60. package/dist/domains/seo/utils/schema-generators/index.d.ts.map +1 -0
  61. package/dist/domains/seo/utils/schema-generators/index.js +6 -0
  62. package/dist/domains/seo/utils/schema-generators/schema.d.ts +135 -0
  63. package/dist/domains/seo/utils/schema-generators/schema.d.ts.map +1 -0
  64. package/dist/domains/seo/utils/schema-generators/schema.js +321 -0
  65. package/dist/domains/seo/utils/schema.d.ts +135 -0
  66. package/dist/domains/seo/utils/schema.d.ts.map +1 -0
  67. package/dist/domains/seo/utils/schema.js +321 -0
  68. package/dist/domains/seo/utils/validation/index.d.ts +7 -0
  69. package/dist/domains/seo/utils/validation/index.d.ts.map +1 -0
  70. package/dist/domains/seo/utils/validation/index.js +6 -0
  71. package/dist/domains/seo/utils/validation/validators.d.ts +39 -0
  72. package/dist/domains/seo/utils/validation/validators.d.ts.map +1 -0
  73. package/dist/domains/seo/utils/validation/validators.js +364 -0
  74. package/dist/domains/seo/utils/validators.d.ts +39 -0
  75. package/dist/domains/seo/utils/validators.d.ts.map +1 -0
  76. package/dist/domains/seo/utils/validators.js +364 -0
  77. package/dist/domains/seo/vite/index.d.ts +8 -0
  78. package/dist/domains/seo/vite/index.d.ts.map +1 -0
  79. package/dist/domains/seo/vite/index.js +6 -0
  80. package/dist/domains/seo/vite/plugin.d.ts +61 -0
  81. package/dist/domains/seo/vite/plugin.d.ts.map +1 -0
  82. package/dist/domains/seo/vite/plugin.js +217 -0
  83. package/dist/index.d.ts +14 -0
  84. package/dist/index.d.ts.map +1 -0
  85. package/dist/index.js +19 -0
  86. package/package.json +57 -7
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Social Media Tag Operations
3
+ *
4
+ * Functions for Open Graph and Twitter Card tags
5
+ */
6
+ import { setMetaTag } from "./basic.js";
7
+ /**
8
+ * Set Open Graph tags
9
+ */
10
+ export const setOpenGraph = (openGraph) => {
11
+ if (!openGraph)
12
+ return;
13
+ const setOG = (property, content) => {
14
+ if (content)
15
+ setMetaTag("property", `og:${property}`, content);
16
+ };
17
+ setOG("title", openGraph.title);
18
+ setOG("description", openGraph.description);
19
+ setOG("url", openGraph.url);
20
+ setOG("type", openGraph.type);
21
+ setOG("site_name", openGraph.siteName);
22
+ setOG("locale", openGraph.locale);
23
+ // Handle multiple images
24
+ if (openGraph.image) {
25
+ if (Array.isArray(openGraph.image)) {
26
+ openGraph.image.forEach((img, index) => {
27
+ const suffix = index > 0 ? `:${index}` : "";
28
+ setOG(`image${suffix}`, img.url);
29
+ if (img.secureUrl)
30
+ setOG(`image:secure_url${suffix}`, img.secureUrl);
31
+ if (img.type)
32
+ setOG(`image:type${suffix}`, img.type);
33
+ if (img.width)
34
+ setOG(`image:width${suffix}`, String(img.width));
35
+ if (img.height)
36
+ setOG(`image:height${suffix}`, String(img.height));
37
+ if (img.alt)
38
+ setOG(`image:alt${suffix}`, img.alt);
39
+ });
40
+ }
41
+ else {
42
+ setOG("image", openGraph.image);
43
+ }
44
+ }
45
+ // Alternate locales
46
+ if (openGraph.alternateLocale) {
47
+ openGraph.alternateLocale.forEach((locale, index) => {
48
+ setMetaTag("property", `og:locale:alternate${index > 0 ? `:${index}` : ""}`, locale);
49
+ });
50
+ }
51
+ // Article specific
52
+ if (openGraph.type === "article" && openGraph.article) {
53
+ setOG("article:published_time", openGraph.article.publishedTime);
54
+ setOG("article:modified_time", openGraph.article.modifiedTime);
55
+ setOG("article:expiration_time", openGraph.article.expirationTime);
56
+ setOG("article:author", openGraph.article.author);
57
+ setOG("article:section", openGraph.article.section);
58
+ if (openGraph.article.tag) {
59
+ openGraph.article.tag.forEach((tag, index) => {
60
+ setMetaTag("property", `og:article:tag${index > 0 ? `:${index}` : ""}`, tag);
61
+ });
62
+ }
63
+ }
64
+ // Product specific
65
+ if (openGraph.type === "product" && openGraph.product) {
66
+ setOG("product:price:amount", String(openGraph.product.price));
67
+ setOG("product:price:currency", openGraph.product.priceCurrency);
68
+ setOG("product:availability", openGraph.product.availability);
69
+ setOG("product:brand", openGraph.product.brand);
70
+ setOG("product:sku", openGraph.product.sku);
71
+ setOG("product:condition", openGraph.product.condition);
72
+ }
73
+ // Profile
74
+ if (openGraph.type === "profile") {
75
+ setOG("profile:first_name", openGraph.firstName);
76
+ setOG("profile:last_name", openGraph.lastName);
77
+ setOG("profile:username", openGraph.username);
78
+ }
79
+ // Music
80
+ if (openGraph.type === "music" && openGraph.music) {
81
+ setOG("music:album", openGraph.music.album);
82
+ setOG("music:musician", openGraph.music.musician);
83
+ setOG("music:song", openGraph.music.song);
84
+ setOG("music:release_date", openGraph.music.releaseDate);
85
+ setOG("music:duration", openGraph.music.duration);
86
+ setOG("music:creator", openGraph.music.creator);
87
+ }
88
+ };
89
+ /**
90
+ * Set Twitter Card tags
91
+ */
92
+ export const setTwitterCard = (twitter, __openGraphImage) => {
93
+ if (!twitter)
94
+ return;
95
+ const setTW = (name, content) => {
96
+ if (content)
97
+ setMetaTag("name", `twitter:${name}`, content);
98
+ };
99
+ setTW("card", twitter.cardType);
100
+ setTW("site", twitter.site);
101
+ setTW("creator", twitter.handle);
102
+ setTW("title", twitter.title);
103
+ setTW("description", twitter.description);
104
+ setTW("image", twitter.image);
105
+ setTW("image:alt", twitter.imageAlt);
106
+ // Player
107
+ if (twitter.cardType === "player") {
108
+ setTW("player", twitter.player);
109
+ setTW("player:width", twitter.playerWidth);
110
+ setTW("player:height", twitter.playerHeight);
111
+ setTW("player:stream", twitter.playerStream);
112
+ setTW("player:stream:content_type", twitter.playerStreamContentType);
113
+ }
114
+ // App
115
+ if (twitter.app) {
116
+ if (twitter.app.iphone) {
117
+ setTW("app:name:iphone", twitter.app.iphone.name);
118
+ setTW("app:id:iphone", twitter.app.iphone.id);
119
+ setTW("app:url:iphone", twitter.app.iphone.url);
120
+ }
121
+ if (twitter.app.ipad) {
122
+ setTW("app:name:ipad", twitter.app.ipad.name);
123
+ setTW("app:id:ipad", twitter.app.ipad.id);
124
+ setTW("app:url:ipad", twitter.app.ipad.url);
125
+ }
126
+ if (twitter.app.googleplay) {
127
+ setTW("app:name:googleplay", twitter.app.googleplay.name);
128
+ setTW("app:id:googleplay", twitter.app.googleplay.id);
129
+ setTW("app:url:googleplay", twitter.app.googleplay.url);
130
+ }
131
+ }
132
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Schema.org Generators
3
+ *
4
+ * Helper functions to generate valid Schema.org structured data
5
+ */
6
+ export { generateArticleSchema, generateProductSchema, generateOrganizationSchema, generateLocalBusinessSchema, generateBreadcrumbSchema, generateFAQSchema, generateWebSiteSchema, generatePersonSchema, generateVideoSchema, } from "./schema.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/domains/seo/utils/schema-generators/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,2BAA2B,EAC3B,wBAAwB,EACxB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Schema.org Generators
3
+ *
4
+ * Helper functions to generate valid Schema.org structured data
5
+ */
6
+ export { generateArticleSchema, generateProductSchema, generateOrganizationSchema, generateLocalBusinessSchema, generateBreadcrumbSchema, generateFAQSchema, generateWebSiteSchema, generatePersonSchema, generateVideoSchema, } from "./schema.js";
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Schema.org JSON-LD Generators
3
+ *
4
+ * Helper functions to generate valid Schema.org structured data
5
+ * for various content types like articles, products, organizations, etc.
6
+ */
7
+ import type { ArticleJsonLd, ProductJsonLd, OrganizationJsonLd, LocalBusinessJsonLd, BreadcrumbJsonLd, FAQJsonLd, WebSiteJsonLd, PersonJsonLd, VideoJsonLd, SchemaGeneratorOptions } from "../../types/schema.js";
8
+ export interface ArticleSchemaInput {
9
+ headline: string;
10
+ description?: string;
11
+ image: string | string[];
12
+ datePublished: string;
13
+ dateModified?: string;
14
+ authorName: string;
15
+ authorUrl?: string;
16
+ authorType?: "Person" | "Organization";
17
+ publisherName: string;
18
+ publisherLogo: string;
19
+ publisherUrl?: string;
20
+ url?: string;
21
+ articleSection?: string;
22
+ wordCount?: number;
23
+ keywords?: string | string[];
24
+ inLanguage?: string;
25
+ type?: "Article" | "NewsArticle" | "BlogPosting";
26
+ }
27
+ export declare const generateArticleSchema: (input: ArticleSchemaInput, options?: SchemaGeneratorOptions) => ArticleJsonLd;
28
+ export interface ProductSchemaInput {
29
+ name: string;
30
+ description?: string;
31
+ image: string | string[];
32
+ price: number;
33
+ priceCurrency: string;
34
+ availability?: "InStock" | "OutOfStock" | "PreOrder";
35
+ url?: string;
36
+ brandName?: string;
37
+ sku?: string;
38
+ gtin?: string;
39
+ aggregateRating?: {
40
+ ratingValue: number;
41
+ reviewCount: number;
42
+ };
43
+ }
44
+ export declare const generateProductSchema: (input: ProductSchemaInput, options?: SchemaGeneratorOptions) => ProductJsonLd;
45
+ export interface OrganizationSchemaInput {
46
+ name: string;
47
+ description?: string;
48
+ url?: string;
49
+ logo?: string;
50
+ sameAs?: string[];
51
+ contactPoint?: {
52
+ telephone: string;
53
+ contactType: string;
54
+ email?: string;
55
+ }[];
56
+ address?: {
57
+ streetAddress: string;
58
+ addressLocality: string;
59
+ addressRegion: string;
60
+ postalCode: string;
61
+ addressCountry: string;
62
+ };
63
+ }
64
+ export declare const generateOrganizationSchema: (input: OrganizationSchemaInput, options?: SchemaGeneratorOptions) => OrganizationJsonLd;
65
+ export interface LocalBusinessSchemaInput extends OrganizationSchemaInput {
66
+ address: {
67
+ streetAddress: string;
68
+ addressLocality: string;
69
+ addressRegion: string;
70
+ postalCode: string;
71
+ addressCountry: string;
72
+ };
73
+ geo?: {
74
+ latitude: number;
75
+ longitude: number;
76
+ };
77
+ openingHours?: {
78
+ dayOfWeek: string | string[];
79
+ opens: string;
80
+ closes: string;
81
+ }[];
82
+ priceRange?: string;
83
+ type?: "LocalBusiness" | "Restaurant" | "Store" | "Dentist" | "Hospital";
84
+ }
85
+ export declare const generateLocalBusinessSchema: (input: LocalBusinessSchemaInput, options?: SchemaGeneratorOptions) => LocalBusinessJsonLd;
86
+ export declare const generateBreadcrumbSchema: (items: Array<{
87
+ name: string;
88
+ item: string;
89
+ position?: number;
90
+ }>, options?: SchemaGeneratorOptions) => BreadcrumbJsonLd;
91
+ export interface FAQItemInput {
92
+ question: string;
93
+ answer: string;
94
+ }
95
+ export declare const generateFAQSchema: (faqs: FAQItemInput[], options?: SchemaGeneratorOptions) => FAQJsonLd;
96
+ export interface WebSiteSchemaInput {
97
+ name: string;
98
+ url: string;
99
+ description?: string;
100
+ searchTarget?: string;
101
+ searchQueryParam?: string;
102
+ publisher?: {
103
+ name: string;
104
+ logo?: string;
105
+ };
106
+ }
107
+ export declare const generateWebSiteSchema: (input: WebSiteSchemaInput, options?: SchemaGeneratorOptions) => WebSiteJsonLd;
108
+ export interface PersonSchemaInput {
109
+ name: string;
110
+ givenName?: string;
111
+ familyName?: string;
112
+ jobTitle?: string;
113
+ description?: string;
114
+ image?: string;
115
+ url?: string;
116
+ sameAs?: string[];
117
+ email?: string;
118
+ telephone?: string;
119
+ worksFor?: {
120
+ name: string;
121
+ url?: string;
122
+ };
123
+ }
124
+ export declare const generatePersonSchema: (input: PersonSchemaInput, options?: SchemaGeneratorOptions) => PersonJsonLd;
125
+ export interface VideoSchemaInput {
126
+ name: string;
127
+ description?: string;
128
+ thumbnailUrl: string;
129
+ uploadDate: string;
130
+ duration?: string;
131
+ embedUrl?: string;
132
+ viewCount?: number;
133
+ }
134
+ export declare const generateVideoSchema: (input: VideoSchemaInput, options?: SchemaGeneratorOptions) => VideoJsonLd;
135
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../../src/domains/seo/utils/schema-generators/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,YAAY,EACZ,WAAW,EACX,sBAAsB,EACvB,MAAM,uBAAu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AAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,eAAO,MAAM,oBAAoB,GAC/B,OAAO,iBAAiB,EACxB,UAAU,sBAAsB,KAC/B,YAgCF,CAAC;AAMF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,mBAAmB,GAC9B,OAAO,gBAAgB,EACvB,UAAU,sBAAsB,KAC/B,WA8BF,CAAC"}
@@ -0,0 +1,321 @@
1
+ /**
2
+ * Schema.org JSON-LD Generators
3
+ *
4
+ * Helper functions to generate valid Schema.org structured data
5
+ * for various content types like articles, products, organizations, etc.
6
+ */
7
+ const DEFAULT_CONTEXT = "https://schema.org";
8
+ // ============================================================================
9
+ // Validation Helpers
10
+ // ============================================================================
11
+ const validateRequired = (value, fieldName, strict = false) => {
12
+ if (!value) {
13
+ const message = `[SEO] Schema validation: Required field "${fieldName}" is missing or empty`;
14
+ if (strict) {
15
+ throw new Error(message);
16
+ }
17
+ if (typeof console !== "undefined" && console.warn) {
18
+ console.warn(message);
19
+ }
20
+ return false;
21
+ }
22
+ return true;
23
+ };
24
+ export const generateArticleSchema = (input, options) => {
25
+ const { strict, validate = true } = options || {};
26
+ if (validate) {
27
+ validateRequired(input.headline, "headline", strict);
28
+ validateRequired(input.image, "image", strict);
29
+ validateRequired(input.datePublished, "datePublished", strict);
30
+ validateRequired(input.authorName, "authorName", strict);
31
+ validateRequired(input.publisherName, "publisherName", strict);
32
+ validateRequired(input.publisherLogo, "publisherLogo", strict);
33
+ }
34
+ return {
35
+ "@context": DEFAULT_CONTEXT,
36
+ "@type": input.type || "Article",
37
+ headline: input.headline,
38
+ name: input.headline, // Required by Thing
39
+ description: input.description,
40
+ image: input.image,
41
+ datePublished: input.datePublished,
42
+ dateModified: input.dateModified,
43
+ author: {
44
+ "@type": input.authorType || "Person",
45
+ name: input.authorName,
46
+ url: input.authorUrl,
47
+ },
48
+ publisher: {
49
+ "@context": DEFAULT_CONTEXT,
50
+ "@type": "Organization",
51
+ name: input.publisherName,
52
+ logo: input.publisherLogo,
53
+ url: input.publisherUrl,
54
+ },
55
+ url: input.url,
56
+ articleSection: input.articleSection,
57
+ wordCount: input.wordCount,
58
+ keywords: Array.isArray(input.keywords) ? input.keywords.join(", ") : input.keywords,
59
+ inLanguage: input.inLanguage,
60
+ mainEntityOfPage: {
61
+ "@type": "WebPage",
62
+ "@id": input.url,
63
+ },
64
+ };
65
+ };
66
+ export const generateProductSchema = (input, options) => {
67
+ const { strict, validate = true } = options || {};
68
+ if (validate) {
69
+ validateRequired(input.name, "name", strict);
70
+ validateRequired(input.image, "image", strict);
71
+ validateRequired(input.price, "price", strict);
72
+ validateRequired(input.priceCurrency, "priceCurrency", strict);
73
+ }
74
+ const schema = {
75
+ "@context": DEFAULT_CONTEXT,
76
+ "@type": "Product",
77
+ name: input.name,
78
+ description: input.description,
79
+ image: input.image,
80
+ offers: {
81
+ "@type": "Offer",
82
+ price: input.price.toString(),
83
+ priceCurrency: input.priceCurrency,
84
+ availability: input.availability
85
+ ? `https://schema.org/${input.availability}`
86
+ : undefined,
87
+ url: input.url,
88
+ },
89
+ };
90
+ if (input.brandName) {
91
+ schema.brand = {
92
+ "@type": "Brand",
93
+ name: input.brandName,
94
+ };
95
+ }
96
+ if (input.sku)
97
+ schema.sku = input.sku;
98
+ if (input.gtin)
99
+ schema.gtin = input.gtin;
100
+ if (input.aggregateRating) {
101
+ schema.aggregateRating = {
102
+ "@type": "AggregateRating",
103
+ ratingValue: input.aggregateRating.ratingValue,
104
+ reviewCount: input.aggregateRating.reviewCount,
105
+ bestRating: 5,
106
+ worstRating: 1,
107
+ };
108
+ }
109
+ return schema;
110
+ };
111
+ export const generateOrganizationSchema = (input, options) => {
112
+ const { strict, validate = true } = options || {};
113
+ if (validate) {
114
+ validateRequired(input.name, "name", strict);
115
+ }
116
+ const schema = {
117
+ "@context": DEFAULT_CONTEXT,
118
+ "@type": "Organization",
119
+ name: input.name,
120
+ description: input.description,
121
+ url: input.url,
122
+ logo: input.logo,
123
+ sameAs: input.sameAs,
124
+ };
125
+ if (input.contactPoint) {
126
+ schema.contactPoint = input.contactPoint.map((cp) => ({
127
+ "@type": "ContactPoint",
128
+ telephone: cp.telephone,
129
+ contactType: cp.contactType,
130
+ email: cp.email,
131
+ }));
132
+ }
133
+ if (input.address) {
134
+ schema.address = {
135
+ "@type": "PostalAddress",
136
+ ...input.address,
137
+ };
138
+ }
139
+ return schema;
140
+ };
141
+ export const generateLocalBusinessSchema = (input, options) => {
142
+ const { strict, validate = true } = options || {};
143
+ if (validate) {
144
+ validateRequired(input.name, "name", strict);
145
+ validateRequired(input.address, "address", strict);
146
+ }
147
+ const schema = {
148
+ "@context": DEFAULT_CONTEXT,
149
+ "@type": input.type || "LocalBusiness",
150
+ name: input.name,
151
+ description: input.description,
152
+ url: input.url,
153
+ logo: input.logo,
154
+ address: {
155
+ "@type": "PostalAddress",
156
+ ...input.address,
157
+ },
158
+ priceRange: input.priceRange,
159
+ };
160
+ if (input.geo) {
161
+ schema.geo = {
162
+ "@type": "GeoCoordinates",
163
+ latitude: input.geo.latitude,
164
+ longitude: input.geo.longitude,
165
+ };
166
+ }
167
+ if (input.openingHours) {
168
+ schema.openingHoursSpecification = input.openingHours.map((oh) => ({
169
+ "@type": "OpeningHoursSpecification",
170
+ dayOfWeek: oh.dayOfWeek,
171
+ opens: oh.opens,
172
+ closes: oh.closes,
173
+ }));
174
+ }
175
+ if (input.contactPoint) {
176
+ schema.contactPoint = input.contactPoint.map((cp) => ({
177
+ "@type": "ContactPoint",
178
+ telephone: cp.telephone,
179
+ contactType: cp.contactType,
180
+ email: cp.email,
181
+ }));
182
+ }
183
+ if (input.sameAs) {
184
+ schema.sameAs = input.sameAs;
185
+ }
186
+ return schema;
187
+ };
188
+ // ============================================================================
189
+ // Breadcrumb Schema Generator
190
+ // ============================================================================
191
+ export const generateBreadcrumbSchema = (items, options) => {
192
+ const { strict, validate = true } = options || {};
193
+ if (validate && items.length === 0) {
194
+ const message = "[SEO] Breadcrumb schema requires at least one item";
195
+ if (strict) {
196
+ throw new Error(message);
197
+ }
198
+ console.warn(message);
199
+ }
200
+ return {
201
+ "@context": DEFAULT_CONTEXT,
202
+ "@type": "BreadcrumbList",
203
+ itemListElement: items.map((item, index) => ({
204
+ "@type": "ListItem",
205
+ position: item.position || index + 1,
206
+ name: item.name,
207
+ item: item.item,
208
+ })),
209
+ };
210
+ };
211
+ export const generateFAQSchema = (faqs, options) => {
212
+ const { strict, validate = true } = options || {};
213
+ if (validate) {
214
+ validateRequired(faqs, "faqs", strict);
215
+ if (faqs.length === 0) {
216
+ const message = "[SEO] FAQ schema requires at least one FAQ item";
217
+ if (strict) {
218
+ throw new Error(message);
219
+ }
220
+ console.warn(message);
221
+ }
222
+ }
223
+ return {
224
+ "@context": DEFAULT_CONTEXT,
225
+ "@type": "FAQPage",
226
+ mainEntity: faqs.map((faq) => ({
227
+ "@type": "Question",
228
+ name: faq.question,
229
+ acceptedAnswer: {
230
+ "@type": "Answer",
231
+ text: faq.answer,
232
+ },
233
+ })),
234
+ };
235
+ };
236
+ export const generateWebSiteSchema = (input, options) => {
237
+ const { strict, validate = true } = options || {};
238
+ if (validate) {
239
+ validateRequired(input.name, "name", strict);
240
+ validateRequired(input.url, "url", strict);
241
+ }
242
+ const schema = {
243
+ "@context": DEFAULT_CONTEXT,
244
+ "@type": "WebSite",
245
+ name: input.name,
246
+ url: input.url,
247
+ description: input.description,
248
+ };
249
+ if (input.searchTarget) {
250
+ schema.potentialAction = {
251
+ "@type": "SearchAction",
252
+ target: input.searchTarget,
253
+ "query-input": input.searchQueryParam || "required name=search_term_string",
254
+ };
255
+ }
256
+ if (input.publisher) {
257
+ schema.publisher = {
258
+ "@context": DEFAULT_CONTEXT,
259
+ "@type": "Organization",
260
+ name: input.publisher.name,
261
+ logo: input.publisher.logo,
262
+ };
263
+ }
264
+ return schema;
265
+ };
266
+ export const generatePersonSchema = (input, options) => {
267
+ const { strict, validate = true } = options || {};
268
+ if (validate) {
269
+ validateRequired(input.name, "name", strict);
270
+ }
271
+ const schema = {
272
+ "@context": DEFAULT_CONTEXT,
273
+ "@type": "Person",
274
+ name: input.name,
275
+ givenName: input.givenName,
276
+ familyName: input.familyName,
277
+ jobTitle: input.jobTitle,
278
+ description: input.description,
279
+ image: input.image,
280
+ url: input.url,
281
+ sameAs: input.sameAs,
282
+ email: input.email,
283
+ telephone: input.telephone,
284
+ };
285
+ if (input.worksFor) {
286
+ schema.worksFor = {
287
+ "@context": DEFAULT_CONTEXT,
288
+ "@type": "Organization",
289
+ name: input.worksFor.name,
290
+ url: input.worksFor.url,
291
+ };
292
+ }
293
+ return schema;
294
+ };
295
+ export const generateVideoSchema = (input, options) => {
296
+ const { strict, validate = true } = options || {};
297
+ if (validate) {
298
+ validateRequired(input.name, "name", strict);
299
+ validateRequired(input.thumbnailUrl, "thumbnailUrl", strict);
300
+ validateRequired(input.uploadDate, "uploadDate", strict);
301
+ }
302
+ const schema = {
303
+ "@context": DEFAULT_CONTEXT,
304
+ "@type": "VideoObject",
305
+ name: input.name,
306
+ description: input.description,
307
+ thumbnailUrl: input.thumbnailUrl,
308
+ uploadDate: input.uploadDate,
309
+ duration: input.duration,
310
+ };
311
+ if (input.viewCount) {
312
+ schema.interactionStatistic = {
313
+ "@type": "InteractionCounter",
314
+ interactionType: {
315
+ "@type": "WatchAction",
316
+ },
317
+ userInteractionCount: input.viewCount,
318
+ };
319
+ }
320
+ return schema;
321
+ };