diff --git a/example/app.tsx b/example/app.tsx
index f72befd..405429d 100644
--- a/example/app.tsx
+++ b/example/app.tsx
@@ -9,6 +9,7 @@ export default ()=>
console.log(Iso.Meta);
const [countGet, countSet] = React.useState(1);
return
+
Title!!
subtitle
diff --git a/example/deep/component.tsx b/example/deep/component.tsx
index 6c39b7d..637cedd 100644
--- a/example/deep/component.tsx
+++ b/example/deep/component.tsx
@@ -1,9 +1,11 @@
import React from "react";
+import * as Iso from "@eno/iso";
export default ()=>
{
const [countGet, countSet] = React.useState(1);
return
+
Component!!!
;
};
\ No newline at end of file
diff --git a/example/deno.json b/example/deno.json
index 7f3779e..bb0e33d 100644
--- a/example/deno.json
+++ b/example/deno.json
@@ -1,4 +1,5 @@
{
+ "compilerOptions": {"lib": ["deno.window", "dom"]},
"imports":
{
"react": "https://esm.sh/preact@10.13.2/compat",
diff --git a/lib/iso.tsx b/lib/iso.tsx
index 9573adf..9243188 100644
--- a/lib/iso.tsx
+++ b/lib/iso.tsx
@@ -1,10 +1,34 @@
import React from "react";
-type Metas = {
- Title?:string,
- Description?:string
+
+type Meta = {title:string, description:string, keywords:string, image:string, canonical:string }
+type MetaKeys = keyof Meta;
+export const Meta:Meta = {
+ title:"",
+ description:"",
+ keywords:"",
+ image:"",
+ canonical:""
};
-export const Meta:Metas = {
- Title:"hey"
-};
\ No newline at end of file
+type MetasInputs = { [Property in MetaKeys]?: string };
+export const Metas =(props:{concatListed?:boolean; dropUnlisted?:boolean}&MetasInputs):null=>
+{
+ const additive = props.concatListed ? (key:MetaKeys, value:string)=> Meta[key] += value : (key:MetaKeys, value:string)=> Meta[key] = value;
+ const subtractive = props.dropUnlisted ? (key:MetaKeys)=> Meta[key] = "" : (key:MetaKeys)=> {};
+
+ Object.keys(Meta).forEach((key)=>{
+ const metaKey = key as MetaKeys;
+ const propValue = props[metaKey]||"";
+ propValue ? additive(metaKey, propValue) : subtractive(metaKey);
+ })
+
+ console.log(`rendering metas`, Meta)
+
+ if(window.innerWidth)
+ {
+ document.title = Meta.title;
+ }
+
+ return null;
+}
\ No newline at end of file