@umituz/web-seo 1.0.2 → 1.0.4
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/package.json +1 -1
- package/dist/components/SEO.d.ts +0 -4
- package/dist/components/SEO.d.ts.map +0 -1
- package/dist/components/SEO.js +0 -16
- package/dist/core/init.d.ts +0 -11
- package/dist/core/init.d.ts.map +0 -1
- package/dist/core/init.js +0 -34
- package/dist/hooks/useSEO.d.ts +0 -3
- package/dist/hooks/useSEO.d.ts.map +0 -1
- package/dist/hooks/useSEO.js +0 -15
- package/dist/index.d.ts +0 -6
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -4
- package/dist/utils/dom.d.ts +0 -26
- package/dist/utils/dom.d.ts.map +0 -1
- package/dist/utils/dom.js +0 -74
package/package.json
CHANGED
package/dist/components/SEO.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SEO.d.ts","sourceRoot":"","sources":["../../src/components/SEO.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAa,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEvD,eAAO,MAAM,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAcnC,CAAC"}
|
package/dist/components/SEO.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
import { updateSEO } from "../utils/dom.js";
|
|
3
|
-
export const SEO = (props) => {
|
|
4
|
-
useEffect(() => {
|
|
5
|
-
updateSEO(props);
|
|
6
|
-
}, [
|
|
7
|
-
props.title,
|
|
8
|
-
props.description,
|
|
9
|
-
props.lang,
|
|
10
|
-
props.canonical,
|
|
11
|
-
JSON.stringify(props.meta),
|
|
12
|
-
JSON.stringify(props.openGraph),
|
|
13
|
-
JSON.stringify(props.twitter),
|
|
14
|
-
]);
|
|
15
|
-
return null; // Component does not render anything
|
|
16
|
-
};
|
package/dist/core/init.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
interface SEOConfig {
|
|
2
|
-
i18n?: any;
|
|
3
|
-
titleKey?: string;
|
|
4
|
-
descriptionKey?: string;
|
|
5
|
-
defaultImage?: string;
|
|
6
|
-
canonicalPrefix?: string;
|
|
7
|
-
twitterHandle?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare const initSEO: (config: SEOConfig) => void;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=init.d.ts.map
|
package/dist/core/init.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/core/init.ts"],"names":[],"mappings":"AAEA,UAAU,SAAS;IACjB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,OAAO,GAAI,QAAQ,SAAS,SAmCxC,CAAC"}
|
package/dist/core/init.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { updateSEO } from "../utils/dom.js";
|
|
2
|
-
export const initSEO = (config) => {
|
|
3
|
-
if (typeof window === "undefined")
|
|
4
|
-
return;
|
|
5
|
-
const update = () => {
|
|
6
|
-
const lang = config.i18n?.language?.split("-")[0] || "en";
|
|
7
|
-
const title = config.i18n ? config.i18n.t(config.titleKey || "app.title") : document.title;
|
|
8
|
-
const description = config.i18n ? config.i18n.t(config.descriptionKey || "app.description") : "";
|
|
9
|
-
const canonical = config.canonicalPrefix ? `${config.canonicalPrefix}/${lang}` : undefined;
|
|
10
|
-
updateSEO({
|
|
11
|
-
title,
|
|
12
|
-
description,
|
|
13
|
-
lang,
|
|
14
|
-
canonical,
|
|
15
|
-
openGraph: {
|
|
16
|
-
title,
|
|
17
|
-
description,
|
|
18
|
-
type: "website",
|
|
19
|
-
image: config.defaultImage,
|
|
20
|
-
url: canonical,
|
|
21
|
-
},
|
|
22
|
-
twitter: {
|
|
23
|
-
cardType: "summary_large_image",
|
|
24
|
-
site: config.twitterHandle,
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
// Initial call
|
|
29
|
-
update();
|
|
30
|
-
// Listen for language changes if i18next is provided
|
|
31
|
-
if (config.i18n && typeof config.i18n.on === "function") {
|
|
32
|
-
config.i18n.on("languageChanged", update);
|
|
33
|
-
}
|
|
34
|
-
};
|
package/dist/hooks/useSEO.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSEO.d.ts","sourceRoot":"","sources":["../../src/hooks/useSEO.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEvD,eAAO,MAAM,MAAM,GAAI,SAAS,SAAS,SAYxC,CAAC"}
|
package/dist/hooks/useSEO.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
import { updateSEO } from "../utils/dom.js";
|
|
3
|
-
export const useSEO = (options) => {
|
|
4
|
-
useEffect(() => {
|
|
5
|
-
updateSEO(options);
|
|
6
|
-
}, [
|
|
7
|
-
options.title,
|
|
8
|
-
options.description,
|
|
9
|
-
options.lang,
|
|
10
|
-
options.canonical,
|
|
11
|
-
JSON.stringify(options.meta),
|
|
12
|
-
JSON.stringify(options.openGraph),
|
|
13
|
-
JSON.stringify(options.twitter),
|
|
14
|
-
]);
|
|
15
|
-
};
|
package/dist/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { SEO } from "./components/SEO.js";
|
|
2
|
-
export { useSEO } from "./hooks/useSEO.js";
|
|
3
|
-
export { updateSEO } from "./utils/dom.js";
|
|
4
|
-
export { initSEO } from "./core/init.js";
|
|
5
|
-
export type { SEOptions, MetaTag } from "./utils/dom.js";
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
DELETED
package/dist/utils/dom.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export interface MetaTag {
|
|
2
|
-
name?: string;
|
|
3
|
-
property?: string;
|
|
4
|
-
content: string;
|
|
5
|
-
}
|
|
6
|
-
export interface SEOptions {
|
|
7
|
-
title?: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
lang?: string;
|
|
10
|
-
canonical?: string;
|
|
11
|
-
meta?: MetaTag[];
|
|
12
|
-
openGraph?: {
|
|
13
|
-
type?: string;
|
|
14
|
-
url?: string;
|
|
15
|
-
title?: string;
|
|
16
|
-
description?: string;
|
|
17
|
-
image?: string;
|
|
18
|
-
};
|
|
19
|
-
twitter?: {
|
|
20
|
-
cardType?: string;
|
|
21
|
-
site?: string;
|
|
22
|
-
handle?: string;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
export declare const updateSEO: (options: SEOptions) => void;
|
|
26
|
-
//# sourceMappingURL=dom.d.ts.map
|
package/dist/utils/dom.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/utils/dom.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;IACjB,SAAS,CAAC,EAAE;QACV,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAcD,eAAO,MAAM,SAAS,GAAI,SAAS,SAAS,SAuD3C,CAAC"}
|
package/dist/utils/dom.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
const setMetaTag = (attrName, attrValue, content) => {
|
|
2
|
-
if (typeof document === "undefined")
|
|
3
|
-
return;
|
|
4
|
-
let element = document.querySelector(`meta[${attrName}="${attrValue}"]`);
|
|
5
|
-
if (!element) {
|
|
6
|
-
element = document.createElement("meta");
|
|
7
|
-
element.setAttribute(attrName, attrValue);
|
|
8
|
-
document.head.appendChild(element);
|
|
9
|
-
}
|
|
10
|
-
element.setAttribute("content", content);
|
|
11
|
-
};
|
|
12
|
-
export const updateSEO = (options) => {
|
|
13
|
-
if (typeof document === "undefined")
|
|
14
|
-
return;
|
|
15
|
-
// Title
|
|
16
|
-
if (options.title) {
|
|
17
|
-
document.title = options.title;
|
|
18
|
-
}
|
|
19
|
-
// Language
|
|
20
|
-
if (options.lang) {
|
|
21
|
-
document.documentElement.lang = options.lang;
|
|
22
|
-
}
|
|
23
|
-
// Description
|
|
24
|
-
if (options.description) {
|
|
25
|
-
setMetaTag("name", "description", options.description);
|
|
26
|
-
}
|
|
27
|
-
// Canonical
|
|
28
|
-
if (options.canonical) {
|
|
29
|
-
let link = document.querySelector('link[rel="canonical"]');
|
|
30
|
-
if (!link) {
|
|
31
|
-
link = document.createElement("link");
|
|
32
|
-
link.setAttribute("rel", "canonical");
|
|
33
|
-
document.head.appendChild(link);
|
|
34
|
-
}
|
|
35
|
-
link.setAttribute("href", options.canonical);
|
|
36
|
-
}
|
|
37
|
-
// Custom Meta
|
|
38
|
-
if (options.meta && Array.isArray(options.meta)) {
|
|
39
|
-
options.meta.forEach(m => {
|
|
40
|
-
if (m.name)
|
|
41
|
-
setMetaTag("name", m.name, m.content);
|
|
42
|
-
if (m.property)
|
|
43
|
-
setMetaTag("property", m.property, m.content);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
// Open Graph
|
|
47
|
-
if (options.openGraph) {
|
|
48
|
-
if (options.openGraph.title)
|
|
49
|
-
setMetaTag("property", "og:title", options.openGraph.title);
|
|
50
|
-
if (options.openGraph.description)
|
|
51
|
-
setMetaTag("property", "og:description", options.openGraph.description);
|
|
52
|
-
if (options.openGraph.url)
|
|
53
|
-
setMetaTag("property", "og:url", options.openGraph.url);
|
|
54
|
-
if (options.openGraph.type)
|
|
55
|
-
setMetaTag("property", "og:type", options.openGraph.type);
|
|
56
|
-
if (options.openGraph.image)
|
|
57
|
-
setMetaTag("property", "og:image", options.openGraph.image);
|
|
58
|
-
}
|
|
59
|
-
// Twitter
|
|
60
|
-
if (options.twitter) {
|
|
61
|
-
if (options.twitter.cardType)
|
|
62
|
-
setMetaTag("name", "twitter:card", options.twitter.cardType);
|
|
63
|
-
if (options.twitter.site)
|
|
64
|
-
setMetaTag("name", "twitter:site", options.twitter.site);
|
|
65
|
-
if (options.twitter.handle)
|
|
66
|
-
setMetaTag("name", "twitter:creator", options.twitter.handle);
|
|
67
|
-
if (options.description)
|
|
68
|
-
setMetaTag("name", "twitter:description", options.description);
|
|
69
|
-
if (options.title)
|
|
70
|
-
setMetaTag("name", "twitter:title", options.title);
|
|
71
|
-
if (options.openGraph?.image)
|
|
72
|
-
setMetaTag("name", "twitter:image", options.openGraph.image);
|
|
73
|
-
}
|
|
74
|
-
};
|