@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,224 @@
1
+ /**
2
+ * SEO DOM Manager
3
+ *
4
+ * Main entry point for updating SEO elements in the DOM
5
+ */
6
+ import { setMetaTag, setLinkTag, setRobotsMeta } from "./meta-tags/basic.js";
7
+ import { setHreflangTags, setFavicon, setAppleTouchIcon, setMaskIcon, setThemeColor, setViewport, } from "./meta-tags/advanced.js";
8
+ import { setOpenGraph, setTwitterCard } from "./meta-tags/social.js";
9
+ import { setPreloadHints, setPreconnectHints, setDnsPrefetchHints, } from "./meta-tags/performance.js";
10
+ /**
11
+ * Update SEO elements in the DOM
12
+ */
13
+ export const updateSEO = (options) => {
14
+ if (typeof document === "undefined")
15
+ return;
16
+ // Title with template support
17
+ if (options.title) {
18
+ const title = options.titleTemplate
19
+ ? options.titleTemplate.replace("%s", options.title)
20
+ : options.title;
21
+ document.title = title;
22
+ }
23
+ // Language
24
+ if (options.lang) {
25
+ document.documentElement.lang = options.lang;
26
+ }
27
+ // Description
28
+ if (options.description) {
29
+ setMetaTag("name", "description", options.description);
30
+ }
31
+ // Canonical
32
+ if (options.canonical) {
33
+ setLinkTag({ rel: "canonical", href: options.canonical });
34
+ }
35
+ // Robots
36
+ if (options.robots !== undefined) {
37
+ // Handle both RobotsMeta and RobotsDirective[] types
38
+ if (Array.isArray(options.robots)) {
39
+ // Convert directive array to RobotsMeta object
40
+ const robotsMeta = {};
41
+ options.robots.forEach((directive) => {
42
+ switch (directive) {
43
+ case "index":
44
+ robotsMeta.index = true;
45
+ break;
46
+ case "noindex":
47
+ robotsMeta.index = false;
48
+ break;
49
+ case "follow":
50
+ robotsMeta.follow = true;
51
+ break;
52
+ case "nofollow":
53
+ robotsMeta.follow = false;
54
+ break;
55
+ case "noarchive":
56
+ robotsMeta.archive = false;
57
+ break;
58
+ case "nosnippet":
59
+ robotsMeta.snippet = false;
60
+ break;
61
+ case "notranslate":
62
+ robotsMeta.translate = false;
63
+ break;
64
+ case "noimageindex":
65
+ robotsMeta.imageIndex = false;
66
+ break;
67
+ }
68
+ });
69
+ setRobotsMeta(robotsMeta);
70
+ }
71
+ else {
72
+ setRobotsMeta(options.robots);
73
+ }
74
+ }
75
+ // Viewport
76
+ if (options.viewport) {
77
+ setViewport(options.viewport);
78
+ }
79
+ // Theme Color
80
+ if (options.themeColor) {
81
+ setThemeColor(options.themeColor);
82
+ }
83
+ // Favicon
84
+ if (options.favicon) {
85
+ setFavicon(options.favicon);
86
+ }
87
+ if (options.appleTouchIcon) {
88
+ setAppleTouchIcon(options.appleTouchIcon);
89
+ }
90
+ if (options.maskIcon) {
91
+ setMaskIcon(options.maskIcon);
92
+ }
93
+ // Hreflang
94
+ if (options.hreflang && options.hreflang.length > 0) {
95
+ setHreflangTags(options.hreflang);
96
+ }
97
+ // Performance Hints
98
+ if (options.preload && options.preload.length > 0) {
99
+ setPreloadHints(options.preload);
100
+ }
101
+ if (options.preconnect && options.preconnect.length > 0) {
102
+ setPreconnectHints(options.preconnect);
103
+ }
104
+ if (options.dnsPrefetch && options.dnsPrefetch.length > 0) {
105
+ setDnsPrefetchHints(options.dnsPrefetch);
106
+ }
107
+ // Custom Meta Tags
108
+ if (options.meta && Array.isArray(options.meta)) {
109
+ options.meta.forEach((m) => {
110
+ if (m.name)
111
+ setMetaTag("name", m.name, m.content);
112
+ if (m.property)
113
+ setMetaTag("property", m.property, m.content);
114
+ if (m.httpEquiv)
115
+ setMetaTag("httpEquiv", m.httpEquiv, m.content);
116
+ if (m.charset)
117
+ setMetaTag("charset", m.charset);
118
+ });
119
+ }
120
+ // Custom Link Tags
121
+ if (options.link && Array.isArray(options.link)) {
122
+ options.link.forEach((link) => {
123
+ const attrs = { rel: link.rel, href: link.href };
124
+ if (link.type)
125
+ attrs.type = link.type;
126
+ if (link.sizes)
127
+ attrs.sizes = link.sizes;
128
+ if (link.media)
129
+ attrs.media = link.media;
130
+ if (link.crossOrigin)
131
+ attrs.crossorigin = link.crossOrigin;
132
+ if (link.as)
133
+ attrs.as = link.as;
134
+ setLinkTag(attrs);
135
+ });
136
+ }
137
+ // Open Graph
138
+ setOpenGraph(options.openGraph);
139
+ // Twitter Card
140
+ setTwitterCard(options.twitter, options.openGraph);
141
+ // Additional Meta Tags (backward compatibility)
142
+ if (options.additionalMetaTags && Array.isArray(options.additionalMetaTags)) {
143
+ options.additionalMetaTags.forEach((m) => {
144
+ if (m.name)
145
+ setMetaTag("name", m.name, m.content);
146
+ if (m.property)
147
+ setMetaTag("property", m.property, m.content);
148
+ });
149
+ }
150
+ // Additional Link Tags (backward compatibility)
151
+ if (options.additionalLinkTags && Array.isArray(options.additionalLinkTags)) {
152
+ options.additionalLinkTags.forEach((link) => {
153
+ const attrs = { rel: link.rel, href: link.href };
154
+ if (link.type)
155
+ attrs.type = link.type;
156
+ if (link.sizes)
157
+ attrs.sizes = link.sizes;
158
+ if (link.media)
159
+ attrs.media = link.media;
160
+ if (link.crossOrigin)
161
+ attrs.crossorigin = link.crossOrigin;
162
+ if (link.as)
163
+ attrs.as = link.as;
164
+ setLinkTag(attrs);
165
+ });
166
+ }
167
+ };
168
+ /**
169
+ * Remove all SEO meta tags added by this library
170
+ */
171
+ export const clearSEO = () => {
172
+ if (typeof document === "undefined")
173
+ return;
174
+ // Remove all meta tags with data-seo attribute
175
+ document.querySelectorAll('meta[data-seo="true"]').forEach((el) => el.remove());
176
+ // Remove all link tags with data-seo attribute
177
+ document.querySelectorAll('link[data-seo="true"]').forEach((el) => el.remove());
178
+ // Reset title
179
+ document.title = "";
180
+ };
181
+ /**
182
+ * Get current SEO state from DOM
183
+ */
184
+ export const getCurrentSEOState = () => {
185
+ if (typeof document === "undefined")
186
+ return null;
187
+ const metaTags = [];
188
+ const linkTags = [];
189
+ // Get all meta tags
190
+ document.querySelectorAll("meta").forEach((meta) => {
191
+ const name = meta.getAttribute("name");
192
+ const property = meta.getAttribute("property");
193
+ const content = meta.getAttribute("content");
194
+ if (content) {
195
+ if (name) {
196
+ metaTags.push({ name, content });
197
+ }
198
+ else if (property) {
199
+ metaTags.push({ property, content });
200
+ }
201
+ }
202
+ });
203
+ // Get all link tags
204
+ document.querySelectorAll("link").forEach((link) => {
205
+ const rel = link.getAttribute("rel");
206
+ const href = link.getAttribute("href");
207
+ const type = link.getAttribute("type");
208
+ const sizes = link.getAttribute("sizes");
209
+ if (rel && href) {
210
+ linkTags.push({
211
+ rel,
212
+ href,
213
+ ...(type && { type }),
214
+ ...(sizes && { sizes }),
215
+ });
216
+ }
217
+ });
218
+ return {
219
+ title: document.title,
220
+ lang: document.documentElement.lang,
221
+ metaTags,
222
+ linkTags,
223
+ };
224
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * SEO Utils
3
+ *
4
+ * Utility functions for SEO management
5
+ */
6
+ export { updateSEO, clearSEO, getCurrentSEOState } from "./dom.js";
7
+ export * from "./meta-tags/index.js";
8
+ export { generateArticleSchema, generateProductSchema, generateOrganizationSchema, generateLocalBusinessSchema, generateBreadcrumbSchema, generateFAQSchema, generateWebSiteSchema, generatePersonSchema, generateVideoSchema, } from "./schema-generators/index.js";
9
+ export { validateSEO, auditSEO, isValidUrl, validateUrl, validateTitleLength, validateDescriptionLength, validateOpenGraphImage, validateHreflangEntry, truncateForSEO, generateSlug, } from "./validation/index.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/domains/seo/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGnE,cAAc,sBAAsB,CAAC;AAGrC,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,2BAA2B,EAC3B,wBAAwB,EACxB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,WAAW,EACX,QAAQ,EACR,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,yBAAyB,EACzB,sBAAsB,EACtB,qBAAqB,EACrB,cAAc,EACd,YAAY,GACb,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * SEO Utils
3
+ *
4
+ * Utility functions for SEO management
5
+ */
6
+ // Core DOM operations
7
+ export { updateSEO, clearSEO, getCurrentSEOState } from "./dom.js";
8
+ // Meta tag utilities
9
+ export * from "./meta-tags/index.js";
10
+ // Schema generators
11
+ export { generateArticleSchema, generateProductSchema, generateOrganizationSchema, generateLocalBusinessSchema, generateBreadcrumbSchema, generateFAQSchema, generateWebSiteSchema, generatePersonSchema, generateVideoSchema, } from "./schema-generators/index.js";
12
+ // Validators
13
+ export { validateSEO, auditSEO, isValidUrl, validateUrl, validateTitleLength, validateDescriptionLength, validateOpenGraphImage, validateHreflangEntry, truncateForSEO, generateSlug, } from "./validation/index.js";
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Advanced Meta Tag Operations
3
+ *
4
+ * Functions for hreflang, favicon, theme color, and viewport
5
+ */
6
+ import type { HreflangEntry } from "../../types/index.js";
7
+ /**
8
+ * Set hreflang tags for international SEO
9
+ */
10
+ export declare const setHreflangTags: (hreflang: HreflangEntry[]) => void;
11
+ /**
12
+ * Set favicon
13
+ */
14
+ export declare const setFavicon: (href: string) => void;
15
+ /**
16
+ * Set Apple touch icon
17
+ */
18
+ export declare const setAppleTouchIcon: (href: string) => void;
19
+ /**
20
+ * Set mask icon for Safari
21
+ */
22
+ export declare const setMaskIcon: (href: string, color?: string) => void;
23
+ /**
24
+ * Set theme color
25
+ */
26
+ export declare const setThemeColor: (color: string) => void;
27
+ /**
28
+ * Set viewport
29
+ */
30
+ export declare const setViewport: (content: string) => void;
31
+ //# sourceMappingURL=advanced.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../../../../../src/domains/seo/utils/meta-tags/advanced.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,aAAa,EAAE,SAcxD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,SAGtC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,SAG7C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,EAAE,QAAQ,MAAM,SAGvD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,SAU1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,SAU1C,CAAC"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Advanced Meta Tag Operations
3
+ *
4
+ * Functions for hreflang, favicon, theme color, and viewport
5
+ */
6
+ import { setLinkTag } from "./basic.js";
7
+ /**
8
+ * Set hreflang tags for international SEO
9
+ */
10
+ export const setHreflangTags = (hreflang) => {
11
+ if (typeof document === "undefined")
12
+ return;
13
+ // Remove existing hreflang tags
14
+ document.querySelectorAll('link[rel="alternate"][hreflang]').forEach((el) => el.remove());
15
+ // Add new hreflang tags
16
+ hreflang.forEach((entry) => {
17
+ setLinkTag({
18
+ rel: "alternate",
19
+ hreflang: entry.lang,
20
+ href: entry.url,
21
+ });
22
+ });
23
+ };
24
+ /**
25
+ * Set favicon
26
+ */
27
+ export const setFavicon = (href) => {
28
+ if (typeof document === "undefined")
29
+ return;
30
+ setLinkTag({ rel: "icon", href, type: "image/x-icon" });
31
+ };
32
+ /**
33
+ * Set Apple touch icon
34
+ */
35
+ export const setAppleTouchIcon = (href) => {
36
+ if (typeof document === "undefined")
37
+ return;
38
+ setLinkTag({ rel: "apple-touch-icon", href, sizes: "180x180" });
39
+ };
40
+ /**
41
+ * Set mask icon for Safari
42
+ */
43
+ export const setMaskIcon = (href, color) => {
44
+ if (typeof document === "undefined")
45
+ return;
46
+ setLinkTag({ rel: "mask-icon", href, ...(color && { color }) });
47
+ };
48
+ /**
49
+ * Set theme color
50
+ */
51
+ export const setThemeColor = (color) => {
52
+ if (typeof document === "undefined")
53
+ return;
54
+ let element = document.querySelector('meta[name="theme-color"]');
55
+ if (!element) {
56
+ element = document.createElement("meta");
57
+ element.setAttribute("name", "theme-color");
58
+ document.head.appendChild(element);
59
+ }
60
+ element.setAttribute("content", color);
61
+ };
62
+ /**
63
+ * Set viewport
64
+ */
65
+ export const setViewport = (content) => {
66
+ if (typeof document === "undefined")
67
+ return;
68
+ let element = document.querySelector('meta[name="viewport"]');
69
+ if (!element) {
70
+ element = document.createElement("meta");
71
+ element.setAttribute("name", "viewport");
72
+ document.head.appendChild(element);
73
+ }
74
+ element.setAttribute("content", content);
75
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Basic Meta Tag Operations
3
+ *
4
+ * Core functions for setting meta and link tags
5
+ */
6
+ import type { RobotsMeta } from "../../types/index.js";
7
+ /**
8
+ * Set a meta tag attribute
9
+ */
10
+ export declare const setMetaTag: (attrName: "name" | "property" | "httpEquiv" | "charset", attrValue: string, content?: string) => void;
11
+ /**
12
+ * Set a link tag attribute
13
+ */
14
+ export declare const setLinkTag: (attrs: Record<string, string>) => void;
15
+ /**
16
+ * Set robots meta tag
17
+ */
18
+ export declare const setRobotsMeta: (robots: RobotsMeta | boolean) => void;
19
+ //# sourceMappingURL=basic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"basic.d.ts","sourceRoot":"","sources":["../../../../../src/domains/seo/utils/meta-tags/basic.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,UAAU,GACrB,UAAU,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,EACvD,WAAW,MAAM,EACjB,UAAU,MAAM,SAcjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,SAqBvD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,UAAU,GAAG,OAAO,SA6CzD,CAAC"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Basic Meta Tag Operations
3
+ *
4
+ * Core functions for setting meta and link tags
5
+ */
6
+ /**
7
+ * Set a meta tag attribute
8
+ */
9
+ export const setMetaTag = (attrName, attrValue, content) => {
10
+ if (typeof document === "undefined")
11
+ return;
12
+ let element = document.querySelector(`meta[${attrName}="${attrValue}"]`);
13
+ if (!element) {
14
+ element = document.createElement("meta");
15
+ element.setAttribute(attrName, attrValue);
16
+ document.head.appendChild(element);
17
+ }
18
+ if (content) {
19
+ element.setAttribute("content", content);
20
+ }
21
+ };
22
+ /**
23
+ * Set a link tag attribute
24
+ */
25
+ export const setLinkTag = (attrs) => {
26
+ if (typeof document === "undefined")
27
+ return;
28
+ const rel = attrs.rel;
29
+ if (!rel)
30
+ return;
31
+ // Build selector based on rel and other identifying attributes
32
+ let selector = `link[rel="${rel}"]`;
33
+ if (attrs.href)
34
+ selector += `[href="${attrs.href}"]`;
35
+ if (attrs.sizes)
36
+ selector += `[sizes="${attrs.sizes}"]`;
37
+ if (attrs.type)
38
+ selector += `[type="${attrs.type}"]`;
39
+ let element = document.querySelector(selector);
40
+ if (!element) {
41
+ element = document.createElement("link");
42
+ document.head.appendChild(element);
43
+ }
44
+ Object.entries(attrs).forEach(([key, value]) => {
45
+ element.setAttribute(key, value);
46
+ });
47
+ };
48
+ /**
49
+ * Set robots meta tag
50
+ */
51
+ export const setRobotsMeta = (robots) => {
52
+ if (typeof document === "undefined")
53
+ return;
54
+ let content = "";
55
+ if (typeof robots === "boolean") {
56
+ content = robots ? "index, follow" : "noindex, nofollow";
57
+ }
58
+ else {
59
+ const directives = [];
60
+ if (robots.index !== undefined) {
61
+ directives.push(robots.index ? "index" : "noindex");
62
+ }
63
+ if (robots.follow !== undefined) {
64
+ directives.push(robots.follow ? "follow" : "nofollow");
65
+ }
66
+ if (robots.archive !== undefined) {
67
+ directives.push(robots.archive ? "all" : "noarchive");
68
+ }
69
+ if (robots.snippet !== undefined) {
70
+ directives.push(robots.snippet ? "all" : "nosnippet");
71
+ }
72
+ if (robots.translate !== undefined) {
73
+ directives.push(robots.translate ? "all" : "notranslate");
74
+ }
75
+ if (robots.imageIndex !== undefined) {
76
+ directives.push(robots.imageIndex ? "all" : "noimageindex");
77
+ }
78
+ if (robots.maxSnippet !== undefined) {
79
+ directives.push(`max-snippet:${robots.maxSnippet}`);
80
+ }
81
+ if (robots.maxImagePreview !== undefined) {
82
+ directives.push(`max-image-preview:${robots.maxImagePreview}`);
83
+ }
84
+ if (robots.maxVideoPreview !== undefined) {
85
+ directives.push(`max-video-preview:${robots.maxVideoPreview}`);
86
+ }
87
+ if (robots.unavailableAfter !== undefined) {
88
+ directives.push(`unavailable_after:${robots.unavailableAfter}`);
89
+ }
90
+ content = directives.join(", ");
91
+ }
92
+ setMetaTag("name", "robots", content);
93
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Meta Tags Module
3
+ *
4
+ * All meta tag related utilities
5
+ */
6
+ export { setMetaTag, setLinkTag, setRobotsMeta } from "./basic.js";
7
+ export { setHreflangTags, setFavicon, setAppleTouchIcon, setMaskIcon, setThemeColor, setViewport, } from "./advanced.js";
8
+ export { setOpenGraph, setTwitterCard } from "./social.js";
9
+ export { setPreloadHints, setPreconnectHints, setDnsPrefetchHints, } from "./performance.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/domains/seo/utils/meta-tags/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EACL,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Meta Tags Module
3
+ *
4
+ * All meta tag related utilities
5
+ */
6
+ export { setMetaTag, setLinkTag, setRobotsMeta } from "./basic.js";
7
+ export { setHreflangTags, setFavicon, setAppleTouchIcon, setMaskIcon, setThemeColor, setViewport, } from "./advanced.js";
8
+ export { setOpenGraph, setTwitterCard } from "./social.js";
9
+ export { setPreloadHints, setPreconnectHints, setDnsPrefetchHints, } from "./performance.js";
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Performance Hints
3
+ *
4
+ * Functions for preload, preconnect, and DNS prefetch hints
5
+ */
6
+ import type { PreloadHint, PreconnectOrigin, DnsPrefetchDomain } from "../../types/index.js";
7
+ /**
8
+ * Set preload hints
9
+ */
10
+ export declare const setPreloadHints: (preloads: PreloadHint[]) => void;
11
+ /**
12
+ * Set preconnect hints
13
+ */
14
+ export declare const setPreconnectHints: (origins: PreconnectOrigin[]) => void;
15
+ /**
16
+ * Set DNS prefetch hints
17
+ */
18
+ export declare const setDnsPrefetchHints: (domains: DnsPrefetchDomain[]) => void;
19
+ //# sourceMappingURL=performance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"performance.d.ts","sourceRoot":"","sources":["../../../../../src/domains/seo/utils/meta-tags/performance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG7F;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,WAAW,EAAE,SAuBtD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,gBAAgB,EAAE,SAa7D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,iBAAiB,EAAE,SAS/D,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Performance Hints
3
+ *
4
+ * Functions for preload, preconnect, and DNS prefetch hints
5
+ */
6
+ import { setLinkTag } from "./basic.js";
7
+ /**
8
+ * Set preload hints
9
+ */
10
+ export const setPreloadHints = (preloads) => {
11
+ if (typeof document === "undefined")
12
+ return;
13
+ // Remove existing preload hints for same resources
14
+ preloads.forEach((preload) => {
15
+ const existing = document.querySelector(`link[rel="preload"][href="${preload.href}"]`);
16
+ if (existing)
17
+ existing.remove();
18
+ });
19
+ // Add preload hints
20
+ preloads.forEach((preload) => {
21
+ const attrs = {
22
+ rel: "preload",
23
+ href: preload.href,
24
+ as: preload.as,
25
+ };
26
+ if (preload.type)
27
+ attrs.type = preload.type;
28
+ if (preload.crossOrigin)
29
+ attrs.crossorigin = preload.crossOrigin;
30
+ if (preload.integrity)
31
+ attrs.integrity = preload.integrity;
32
+ setLinkTag(attrs);
33
+ });
34
+ };
35
+ /**
36
+ * Set preconnect hints
37
+ */
38
+ export const setPreconnectHints = (origins) => {
39
+ if (typeof document === "undefined")
40
+ return;
41
+ origins.forEach((origin) => {
42
+ const attrs = {
43
+ rel: "preconnect",
44
+ href: origin.href,
45
+ };
46
+ if (origin.crossOrigin)
47
+ attrs.crossorigin = origin.crossOrigin;
48
+ setLinkTag(attrs);
49
+ });
50
+ };
51
+ /**
52
+ * Set DNS prefetch hints
53
+ */
54
+ export const setDnsPrefetchHints = (domains) => {
55
+ if (typeof document === "undefined")
56
+ return;
57
+ domains.forEach((domain) => {
58
+ setLinkTag({
59
+ rel: "dns-prefetch",
60
+ href: domain.href,
61
+ });
62
+ });
63
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Social Media Tag Operations
3
+ *
4
+ * Functions for Open Graph and Twitter Card tags
5
+ */
6
+ import type { SEOptions } from "../../types/index.js";
7
+ /**
8
+ * Set Open Graph tags
9
+ */
10
+ export declare const setOpenGraph: (openGraph: SEOptions["openGraph"]) => void;
11
+ /**
12
+ * Set Twitter Card tags
13
+ */
14
+ export declare const setTwitterCard: (twitter: SEOptions["twitter"], __openGraphImage?: SEOptions["openGraph"]) => void;
15
+ //# sourceMappingURL=social.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"social.d.ts","sourceRoot":"","sources":["../../../../../src/domains/seo/utils/meta-tags/social.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGtD;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,WAAW,SAAS,CAAC,WAAW,CAAC,SA8E7D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GACzB,SAAS,SAAS,CAAC,SAAS,CAAC,EAC7B,mBAAmB,SAAS,CAAC,WAAW,CAAC,SA2C1C,CAAC"}