@umituz/web-seo 2.0.4 → 2.0.7
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/JsonLd.d.ts +0 -1
- package/dist/domains/seo/components/SEO.d.ts +0 -1
- package/dist/domains/seo/components/index.d.ts +7 -0
- package/dist/domains/seo/components/index.js +7 -0
- package/dist/domains/seo/core/init.d.ts +0 -1
- package/dist/domains/seo/hooks/index.d.ts +7 -0
- package/dist/domains/seo/hooks/index.js +7 -0
- package/dist/domains/seo/hooks/useJsonLd.d.ts +0 -1
- package/dist/domains/seo/hooks/useSEO.d.ts +0 -1
- package/dist/domains/seo/ssr/renderer.d.ts +1 -2
- package/dist/domains/seo/ssr/serializer.d.ts +0 -1
- package/dist/domains/seo/types/index.d.ts +5 -2
- package/dist/domains/seo/types/schema.d.ts +0 -1
- package/dist/domains/seo/utils/dom.d.ts +5 -4
- package/dist/domains/seo/utils/dom.js +9 -322
- package/dist/domains/seo/utils/index.d.ts +9 -0
- package/dist/domains/seo/utils/index.js +13 -0
- package/dist/domains/seo/utils/meta-tags/advanced.d.ts +30 -0
- package/dist/domains/seo/utils/meta-tags/advanced.js +75 -0
- package/dist/domains/seo/utils/meta-tags/basic.d.ts +18 -0
- package/dist/domains/seo/utils/meta-tags/basic.js +93 -0
- package/dist/domains/seo/utils/meta-tags/index.d.ts +9 -0
- package/dist/domains/seo/utils/meta-tags/index.js +9 -0
- package/dist/domains/seo/utils/meta-tags/performance.d.ts +18 -0
- package/dist/domains/seo/utils/meta-tags/performance.js +63 -0
- package/dist/domains/seo/utils/meta-tags/social.d.ts +14 -0
- package/dist/domains/seo/utils/meta-tags/social.js +132 -0
- package/dist/domains/seo/utils/schema-generators/index.d.ts +6 -0
- package/dist/domains/seo/utils/schema-generators/index.js +6 -0
- package/dist/domains/seo/utils/{schema.d.ts → schema-generators/schema.d.ts} +1 -2
- package/dist/domains/seo/utils/validation/index.d.ts +6 -0
- package/dist/domains/seo/utils/validation/index.js +6 -0
- package/dist/domains/seo/utils/{validators.d.ts → validation/validators.d.ts} +1 -2
- package/dist/domains/seo/utils/{validators.js → validation/validators.js} +2 -2
- package/dist/domains/seo/vite/index.d.ts +7 -0
- package/dist/domains/seo/vite/index.js +6 -0
- package/dist/domains/seo/vite/plugin.d.ts +0 -1
- package/dist/domains/seo/vite/plugin.js +6 -4
- package/dist/index.d.ts +13 -2
- package/dist/index.js +17 -4
- package/package.json +24 -3
- package/dist/domains/seo/components/JsonLd.d.ts.map +0 -1
- package/dist/domains/seo/components/SEO.d.ts.map +0 -1
- package/dist/domains/seo/core/init.d.ts.map +0 -1
- package/dist/domains/seo/hooks/useJsonLd.d.ts.map +0 -1
- package/dist/domains/seo/hooks/useSEO.d.ts.map +0 -1
- package/dist/domains/seo/index.d.ts +0 -15
- package/dist/domains/seo/index.d.ts.map +0 -1
- package/dist/domains/seo/index.js +0 -21
- package/dist/domains/seo/ssr/renderer.d.ts.map +0 -1
- package/dist/domains/seo/ssr/serializer.d.ts.map +0 -1
- package/dist/domains/seo/types/index.d.ts.map +0 -1
- package/dist/domains/seo/types/schema.d.ts.map +0 -1
- package/dist/domains/seo/utils/dom.d.ts.map +0 -1
- package/dist/domains/seo/utils/schema.d.ts.map +0 -1
- package/dist/domains/seo/utils/validators.d.ts.map +0 -1
- package/dist/domains/seo/vite/plugin.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- /package/dist/domains/seo/utils/{schema.js → schema-generators/schema.js} +0 -0
|
@@ -37,7 +37,7 @@ export declare const extractSEOData: (options: SEOptions) => string;
|
|
|
37
37
|
export declare const hydrateSEO: (serializedData: string) => void;
|
|
38
38
|
export interface RenderedMetaTag {
|
|
39
39
|
toString(): string;
|
|
40
|
-
toComponent():
|
|
40
|
+
toComponent(): unknown;
|
|
41
41
|
}
|
|
42
42
|
export interface HelmetData {
|
|
43
43
|
base: RenderedMetaTag[];
|
|
@@ -55,4 +55,3 @@ export interface HelmetData {
|
|
|
55
55
|
* Render SEO in Helmet-compatible format
|
|
56
56
|
*/
|
|
57
57
|
export declare const renderAsHelmet: (options: SEOptions) => HelmetData;
|
|
58
|
-
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -171,7 +171,11 @@ export interface SEOConfig {
|
|
|
171
171
|
themeColor?: string;
|
|
172
172
|
favicon?: string;
|
|
173
173
|
appleTouchIcon?: string;
|
|
174
|
-
i18n?:
|
|
174
|
+
i18n?: {
|
|
175
|
+
language?: string;
|
|
176
|
+
t: (key: string) => string;
|
|
177
|
+
on: (event: string, callback: () => void) => void;
|
|
178
|
+
};
|
|
175
179
|
defaultLanguage?: string;
|
|
176
180
|
defaultRobots?: RobotsMeta;
|
|
177
181
|
preconnectOrigins?: string[];
|
|
@@ -187,4 +191,3 @@ export interface SEOValidationResult {
|
|
|
187
191
|
}
|
|
188
192
|
export type SchemaType = "Article" | "NewsArticle" | "BlogPosting" | "Product" | "Organization" | "LocalBusiness" | "BreadcrumbList" | "FAQPage" | "WebSite" | "Person" | "VideoObject" | "AudioObject" | "Book" | "Review" | "AggregateRating";
|
|
189
193
|
export type { JsonLdTypes } from "./schema.js";
|
|
190
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SEO DOM
|
|
2
|
+
* SEO DOM Manager
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* Handles meta tags, link tags, structured data, and performance hints.
|
|
4
|
+
* Main entry point for updating SEO elements in the DOM
|
|
6
5
|
*/
|
|
7
6
|
import type { SEOptions, MetaTag, LinkTag } from "../types/index.js";
|
|
7
|
+
/**
|
|
8
|
+
* Update SEO elements in the DOM
|
|
9
|
+
*/
|
|
8
10
|
export declare const updateSEO: (options: SEOptions) => void;
|
|
9
11
|
/**
|
|
10
12
|
* Remove all SEO meta tags added by this library
|
|
@@ -19,4 +21,3 @@ export declare const getCurrentSEOState: () => {
|
|
|
19
21
|
metaTags: MetaTag[];
|
|
20
22
|
linkTags: LinkTag[];
|
|
21
23
|
} | null;
|
|
22
|
-
//# sourceMappingURL=dom.d.ts.map
|
|
@@ -1,325 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SEO DOM
|
|
2
|
+
* SEO DOM Manager
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
|
|
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
|
|
6
12
|
*/
|
|
7
|
-
// ============================================================================
|
|
8
|
-
// Meta Tag Management
|
|
9
|
-
// ============================================================================
|
|
10
|
-
const setMetaTag = (attrName, attrValue, content) => {
|
|
11
|
-
if (typeof document === "undefined")
|
|
12
|
-
return;
|
|
13
|
-
let element = document.querySelector(`meta[${attrName}="${attrValue}"]`);
|
|
14
|
-
if (!element) {
|
|
15
|
-
element = document.createElement("meta");
|
|
16
|
-
element.setAttribute(attrName, attrValue);
|
|
17
|
-
document.head.appendChild(element);
|
|
18
|
-
}
|
|
19
|
-
if (content) {
|
|
20
|
-
element.setAttribute("content", content);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const setLinkTag = (attrs) => {
|
|
24
|
-
if (typeof document === "undefined")
|
|
25
|
-
return;
|
|
26
|
-
const rel = attrs.rel;
|
|
27
|
-
if (!rel)
|
|
28
|
-
return;
|
|
29
|
-
// Build selector based on rel and other identifying attributes
|
|
30
|
-
let selector = `link[rel="${rel}"]`;
|
|
31
|
-
if (attrs.href)
|
|
32
|
-
selector += `[href="${attrs.href}"]`;
|
|
33
|
-
if (attrs.sizes)
|
|
34
|
-
selector += `[sizes="${attrs.sizes}"]`;
|
|
35
|
-
if (attrs.type)
|
|
36
|
-
selector += `[type="${attrs.type}"]`;
|
|
37
|
-
let element = document.querySelector(selector);
|
|
38
|
-
if (!element) {
|
|
39
|
-
element = document.createElement("link");
|
|
40
|
-
document.head.appendChild(element);
|
|
41
|
-
}
|
|
42
|
-
Object.entries(attrs).forEach(([key, value]) => {
|
|
43
|
-
element.setAttribute(key, value);
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
// ============================================================================
|
|
47
|
-
// Robots Meta Tag
|
|
48
|
-
// ============================================================================
|
|
49
|
-
const setRobotsMeta = (robots) => {
|
|
50
|
-
if (typeof document === "undefined")
|
|
51
|
-
return;
|
|
52
|
-
let content = "";
|
|
53
|
-
if (typeof robots === "boolean") {
|
|
54
|
-
content = robots ? "index, follow" : "noindex, nofollow";
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
const directives = [];
|
|
58
|
-
if (robots.index !== undefined) {
|
|
59
|
-
directives.push(robots.index ? "index" : "noindex");
|
|
60
|
-
}
|
|
61
|
-
if (robots.follow !== undefined) {
|
|
62
|
-
directives.push(robots.follow ? "follow" : "nofollow");
|
|
63
|
-
}
|
|
64
|
-
if (robots.archive !== undefined) {
|
|
65
|
-
directives.push(robots.archive ? "all" : "noarchive");
|
|
66
|
-
}
|
|
67
|
-
if (robots.snippet !== undefined) {
|
|
68
|
-
directives.push(robots.snippet ? "all" : "nosnippet");
|
|
69
|
-
}
|
|
70
|
-
if (robots.translate !== undefined) {
|
|
71
|
-
directives.push(robots.translate ? "all" : "notranslate");
|
|
72
|
-
}
|
|
73
|
-
if (robots.imageIndex !== undefined) {
|
|
74
|
-
directives.push(robots.imageIndex ? "all" : "noimageindex");
|
|
75
|
-
}
|
|
76
|
-
if (robots.maxSnippet !== undefined) {
|
|
77
|
-
directives.push(`max-snippet:${robots.maxSnippet}`);
|
|
78
|
-
}
|
|
79
|
-
if (robots.maxImagePreview !== undefined) {
|
|
80
|
-
directives.push(`max-image-preview:${robots.maxImagePreview}`);
|
|
81
|
-
}
|
|
82
|
-
if (robots.maxVideoPreview !== undefined) {
|
|
83
|
-
directives.push(`max-video-preview:${robots.maxVideoPreview}`);
|
|
84
|
-
}
|
|
85
|
-
if (robots.unavailableAfter !== undefined) {
|
|
86
|
-
directives.push(`unavailable_after:${robots.unavailableAfter}`);
|
|
87
|
-
}
|
|
88
|
-
content = directives.join(", ");
|
|
89
|
-
}
|
|
90
|
-
setMetaTag("name", "robots", content);
|
|
91
|
-
};
|
|
92
|
-
// ============================================================================
|
|
93
|
-
// Hreflang Management
|
|
94
|
-
// ============================================================================
|
|
95
|
-
const setHreflangTags = (hreflang) => {
|
|
96
|
-
if (typeof document === "undefined")
|
|
97
|
-
return;
|
|
98
|
-
// Remove existing hreflang tags
|
|
99
|
-
document.querySelectorAll('link[rel="alternate"][hreflang]').forEach((el) => el.remove());
|
|
100
|
-
// Add new hreflang tags
|
|
101
|
-
hreflang.forEach((entry) => {
|
|
102
|
-
setLinkTag({
|
|
103
|
-
rel: "alternate",
|
|
104
|
-
hreflang: entry.lang,
|
|
105
|
-
href: entry.url,
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
// ============================================================================
|
|
110
|
-
// Favicon Management
|
|
111
|
-
// ============================================================================
|
|
112
|
-
const setFavicon = (href) => {
|
|
113
|
-
if (typeof document === "undefined")
|
|
114
|
-
return;
|
|
115
|
-
setLinkTag({ rel: "icon", href, type: "image/x-icon" });
|
|
116
|
-
};
|
|
117
|
-
const setAppleTouchIcon = (href) => {
|
|
118
|
-
if (typeof document === "undefined")
|
|
119
|
-
return;
|
|
120
|
-
setLinkTag({ rel: "apple-touch-icon", href, sizes: "180x180" });
|
|
121
|
-
};
|
|
122
|
-
const setMaskIcon = (href, color) => {
|
|
123
|
-
if (typeof document === "undefined")
|
|
124
|
-
return;
|
|
125
|
-
setLinkTag({ rel: "mask-icon", href, ...(color && { color }) });
|
|
126
|
-
};
|
|
127
|
-
// ============================================================================
|
|
128
|
-
// Theme Color
|
|
129
|
-
// ============================================================================
|
|
130
|
-
const setThemeColor = (color) => {
|
|
131
|
-
if (typeof document === "undefined")
|
|
132
|
-
return;
|
|
133
|
-
setMetaTag("name", "theme-color", color);
|
|
134
|
-
};
|
|
135
|
-
// ============================================================================
|
|
136
|
-
// Viewport
|
|
137
|
-
// ============================================================================
|
|
138
|
-
const setViewport = (content) => {
|
|
139
|
-
if (typeof document === "undefined")
|
|
140
|
-
return;
|
|
141
|
-
setMetaTag("name", "viewport", content);
|
|
142
|
-
};
|
|
143
|
-
// ============================================================================
|
|
144
|
-
// Performance Hints
|
|
145
|
-
// ============================================================================
|
|
146
|
-
const setPreloadHints = (preloads) => {
|
|
147
|
-
if (typeof document === "undefined")
|
|
148
|
-
return;
|
|
149
|
-
// Remove existing preload hints for same resources
|
|
150
|
-
preloads.forEach((preload) => {
|
|
151
|
-
const existing = document.querySelector(`link[rel="preload"][href="${preload.href}"]`);
|
|
152
|
-
if (existing)
|
|
153
|
-
existing.remove();
|
|
154
|
-
});
|
|
155
|
-
// Add preload hints
|
|
156
|
-
preloads.forEach((preload) => {
|
|
157
|
-
const attrs = {
|
|
158
|
-
rel: "preload",
|
|
159
|
-
href: preload.href,
|
|
160
|
-
as: preload.as,
|
|
161
|
-
};
|
|
162
|
-
if (preload.type)
|
|
163
|
-
attrs.type = preload.type;
|
|
164
|
-
if (preload.crossOrigin)
|
|
165
|
-
attrs.crossorigin = preload.crossOrigin;
|
|
166
|
-
if (preload.integrity)
|
|
167
|
-
attrs.integrity = preload.integrity;
|
|
168
|
-
setLinkTag(attrs);
|
|
169
|
-
});
|
|
170
|
-
};
|
|
171
|
-
const setPreconnectHints = (origins) => {
|
|
172
|
-
if (typeof document === "undefined")
|
|
173
|
-
return;
|
|
174
|
-
origins.forEach((origin) => {
|
|
175
|
-
const attrs = {
|
|
176
|
-
rel: "preconnect",
|
|
177
|
-
href: origin.href,
|
|
178
|
-
};
|
|
179
|
-
if (origin.crossOrigin)
|
|
180
|
-
attrs.crossorigin = origin.crossOrigin;
|
|
181
|
-
setLinkTag(attrs);
|
|
182
|
-
});
|
|
183
|
-
};
|
|
184
|
-
const setDnsPrefetchHints = (domains) => {
|
|
185
|
-
if (typeof document === "undefined")
|
|
186
|
-
return;
|
|
187
|
-
domains.forEach((domain) => {
|
|
188
|
-
setLinkTag({
|
|
189
|
-
rel: "dns-prefetch",
|
|
190
|
-
href: domain.href,
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
};
|
|
194
|
-
// ============================================================================
|
|
195
|
-
// Open Graph (Enhanced)
|
|
196
|
-
// ============================================================================
|
|
197
|
-
const setOpenGraph = (openGraph) => {
|
|
198
|
-
if (!openGraph)
|
|
199
|
-
return;
|
|
200
|
-
const setOG = (property, content) => {
|
|
201
|
-
if (content)
|
|
202
|
-
setMetaTag("property", `og:${property}`, content);
|
|
203
|
-
};
|
|
204
|
-
setOG("title", openGraph.title);
|
|
205
|
-
setOG("description", openGraph.description);
|
|
206
|
-
setOG("url", openGraph.url);
|
|
207
|
-
setOG("type", openGraph.type);
|
|
208
|
-
setOG("site_name", openGraph.siteName);
|
|
209
|
-
setOG("locale", openGraph.locale);
|
|
210
|
-
// Handle multiple images
|
|
211
|
-
if (openGraph.image) {
|
|
212
|
-
if (Array.isArray(openGraph.image)) {
|
|
213
|
-
openGraph.image.forEach((img, index) => {
|
|
214
|
-
const suffix = index > 0 ? `:${index}` : "";
|
|
215
|
-
setOG(`image${suffix}`, img.url);
|
|
216
|
-
if (img.secureUrl)
|
|
217
|
-
setOG(`image:secure_url${suffix}`, img.secureUrl);
|
|
218
|
-
if (img.type)
|
|
219
|
-
setOG(`image:type${suffix}`, img.type);
|
|
220
|
-
if (img.width)
|
|
221
|
-
setOG(`image:width${suffix}`, String(img.width));
|
|
222
|
-
if (img.height)
|
|
223
|
-
setOG(`image:height${suffix}`, String(img.height));
|
|
224
|
-
if (img.alt)
|
|
225
|
-
setOG(`image:alt${suffix}`, img.alt);
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
setOG("image", openGraph.image);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
// Alternate locales
|
|
233
|
-
if (openGraph.alternateLocale) {
|
|
234
|
-
openGraph.alternateLocale.forEach((locale, index) => {
|
|
235
|
-
setMetaTag("property", `og:locale:alternate${index > 0 ? `:${index}` : ""}`, locale);
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
// Article specific
|
|
239
|
-
if (openGraph.type === "article" && openGraph.article) {
|
|
240
|
-
setOG("article:published_time", openGraph.article.publishedTime);
|
|
241
|
-
setOG("article:modified_time", openGraph.article.modifiedTime);
|
|
242
|
-
setOG("article:expiration_time", openGraph.article.expirationTime);
|
|
243
|
-
setOG("article:author", openGraph.article.author);
|
|
244
|
-
setOG("article:section", openGraph.article.section);
|
|
245
|
-
if (openGraph.article.tag) {
|
|
246
|
-
openGraph.article.tag.forEach((tag, index) => {
|
|
247
|
-
setMetaTag("property", `og:article:tag${index > 0 ? `:${index}` : ""}`, tag);
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
// Product specific
|
|
252
|
-
if (openGraph.type === "product" && openGraph.product) {
|
|
253
|
-
setOG("product:price:amount", String(openGraph.product.price));
|
|
254
|
-
setOG("product:price:currency", openGraph.product.priceCurrency);
|
|
255
|
-
setOG("product:availability", openGraph.product.availability);
|
|
256
|
-
setOG("product:brand", openGraph.product.brand);
|
|
257
|
-
setOG("product:sku", openGraph.product.sku);
|
|
258
|
-
setOG("product:condition", openGraph.product.condition);
|
|
259
|
-
}
|
|
260
|
-
// Profile
|
|
261
|
-
if (openGraph.type === "profile") {
|
|
262
|
-
setOG("profile:first_name", openGraph.firstName);
|
|
263
|
-
setOG("profile:last_name", openGraph.lastName);
|
|
264
|
-
setOG("profile:username", openGraph.username);
|
|
265
|
-
}
|
|
266
|
-
// Music
|
|
267
|
-
if (openGraph.type === "music" && openGraph.music) {
|
|
268
|
-
setOG("music:album", openGraph.music.album);
|
|
269
|
-
setOG("music:musician", openGraph.music.musician);
|
|
270
|
-
setOG("music:song", openGraph.music.song);
|
|
271
|
-
setOG("music:release_date", openGraph.music.releaseDate);
|
|
272
|
-
setOG("music:duration", openGraph.music.duration);
|
|
273
|
-
setOG("music:creator", openGraph.music.creator);
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
// ============================================================================
|
|
277
|
-
// Twitter Card (Enhanced)
|
|
278
|
-
// ============================================================================
|
|
279
|
-
const setTwitterCard = (twitter, _openGraphImage) => {
|
|
280
|
-
if (!twitter)
|
|
281
|
-
return;
|
|
282
|
-
const setTW = (name, content) => {
|
|
283
|
-
if (content)
|
|
284
|
-
setMetaTag("name", `twitter:${name}`, content);
|
|
285
|
-
};
|
|
286
|
-
setTW("card", twitter.cardType);
|
|
287
|
-
setTW("site", twitter.site);
|
|
288
|
-
setTW("creator", twitter.handle);
|
|
289
|
-
setTW("title", twitter.title);
|
|
290
|
-
setTW("description", twitter.description);
|
|
291
|
-
setTW("image", twitter.image);
|
|
292
|
-
setTW("image:alt", twitter.imageAlt);
|
|
293
|
-
// Player
|
|
294
|
-
if (twitter.cardType === "player") {
|
|
295
|
-
setTW("player", twitter.player);
|
|
296
|
-
setTW("player:width", twitter.playerWidth);
|
|
297
|
-
setTW("player:height", twitter.playerHeight);
|
|
298
|
-
setTW("player:stream", twitter.playerStream);
|
|
299
|
-
setTW("player:stream:content_type", twitter.playerStreamContentType);
|
|
300
|
-
}
|
|
301
|
-
// App
|
|
302
|
-
if (twitter.app) {
|
|
303
|
-
if (twitter.app.iphone) {
|
|
304
|
-
setTW("app:name:iphone", twitter.app.iphone.name);
|
|
305
|
-
setTW("app:id:iphone", twitter.app.iphone.id);
|
|
306
|
-
setTW("app:url:iphone", twitter.app.iphone.url);
|
|
307
|
-
}
|
|
308
|
-
if (twitter.app.ipad) {
|
|
309
|
-
setTW("app:name:ipad", twitter.app.ipad.name);
|
|
310
|
-
setTW("app:id:ipad", twitter.app.ipad.id);
|
|
311
|
-
setTW("app:url:ipad", twitter.app.ipad.url);
|
|
312
|
-
}
|
|
313
|
-
if (twitter.app.googleplay) {
|
|
314
|
-
setTW("app:name:googleplay", twitter.app.googleplay.name);
|
|
315
|
-
setTW("app:id:googleplay", twitter.app.googleplay.id);
|
|
316
|
-
setTW("app:url:googleplay", twitter.app.googleplay.url);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
// ============================================================================
|
|
321
|
-
// Main SEO Update Function
|
|
322
|
-
// ============================================================================
|
|
323
13
|
export const updateSEO = (options) => {
|
|
324
14
|
if (typeof document === "undefined")
|
|
325
15
|
return;
|
|
@@ -475,9 +165,6 @@ export const updateSEO = (options) => {
|
|
|
475
165
|
});
|
|
476
166
|
}
|
|
477
167
|
};
|
|
478
|
-
// ============================================================================
|
|
479
|
-
// Utility Functions
|
|
480
|
-
// ============================================================================
|
|
481
168
|
/**
|
|
482
169
|
* Remove all SEO meta tags added by this library
|
|
483
170
|
*/
|
|
@@ -0,0 +1,9 @@
|
|
|
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";
|
|
@@ -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,30 @@
|
|
|
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;
|
|
@@ -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,18 @@
|
|
|
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;
|