@umituz/web-seo 1.0.0 → 1.0.1
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/core/init.d.ts +11 -0
- package/dist/core/init.d.ts.map +1 -0
- package/dist/core/init.js +34 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { SEO } from "./components/SEO.js";
|
|
2
2
|
export { useSEO } from "./hooks/useSEO.js";
|
|
3
3
|
export { updateSEO } from "./utils/dom.js";
|
|
4
|
+
export { initSEO } from "./core/init.js";
|
|
4
5
|
export type { SEOptions, MetaTag } from "./utils/dom.js";
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC"}
|
|
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
CHANGED