-
+
Component Route is: {routeGet.Path.toString()}
a link
diff --git a/lib/iso.tsx b/lib/iso.tsx
index df2df88..f000e79 100644
--- a/lib/iso.tsx
+++ b/lib/iso.tsx
@@ -1,33 +1,42 @@
import React from "react";
+type MetasInputs = { [Property in MetaKeys]?: 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:""
-};
-type MetasInputs = { [Property in MetaKeys]?: string };
-export const Metas =(props:{concatListed?:boolean; dropUnlisted?:boolean}&MetasInputs):null=>
+export const Meta =
{
- 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);
- })
- if(window.innerWidth)
+ Meta: {
+ title:"",
+ description:"",
+ keywords:"",
+ image:"",
+ canonical:""
+ } as Meta,
+ Context: React.createContext([{} as Meta, ()=>{}] as [Get:Meta, Set:React.StateUpdater
]),
+ Provider({children}:{children:Children})
{
- document.title = Meta.title;
+ const binding = React.useState(Meta.Meta);
+ return
{children};
+ },
+ Metas(props:{concatListed?:boolean; dropUnlisted?:boolean}&MetasInputs):null
+ {
+ const additive = props.concatListed ? (key:MetaKeys, value:string)=> Meta.Meta[key] += value : (key:MetaKeys, value:string)=> Meta.Meta[key] = value;
+ const subtractive = props.dropUnlisted ? (key:MetaKeys)=> Meta.Meta[key] = "" : (key:MetaKeys)=> {};
+
+ Object.keys(Meta).forEach((key)=>{
+ const metaKey = key as MetaKeys;
+ const propValue = props[metaKey]||"";
+ propValue ? additive(metaKey, propValue) : subtractive(metaKey);
+ })
+ if(window.innerWidth)
+ {
+ document.title = Meta.Meta.title;
+ }
+
+ return null;
}
-
- return null;
-}
+};
export type Children = string | number | React.JSX.Element | React.JSX.Element[];
diff --git a/server.tsx b/server.tsx
index 385f1ff..e4992b3 100644
--- a/server.tsx
+++ b/server.tsx
@@ -226,7 +226,7 @@ FileListen("${url.pathname}", reloadHandler);`;
Iso.Fetch.ServerBlocking = [];
Iso.Fetch.ServerTouched = new Set();
Iso.Fetch.ServerRemove = new Set();
- let app =
;
+ let app =
;
await Prepass(app)
let bake = SSR(app);
while(Iso.Fetch.ServerBlocking.length)
@@ -235,7 +235,7 @@ FileListen("${url.pathname}", reloadHandler);`;
Iso.Fetch.ServerBlocking = [];
// at this point, anything that was requested that was not cached, has now been loaded and cached
// this next render will use cached resources. using a cached resource (if its "Seed" is true) adds it to the "touched" set.
- app =
;
+ app =
;
await Prepass(app)
bake = SSR(app);
}
@@ -255,7 +255,7 @@ FileListen("${url.pathname}", reloadHandler);`;
`
-
${Iso.Meta.title}
+
${Iso.Meta.Meta.title}
@@ -271,7 +271,12 @@ FileListen("${url.pathname}", reloadHandler);`;
Twind.install(CSS);
Fetch.Seed(${JSON.stringify(seed)});
const hmrWrap = H( ()=>H(App) );
- hydrate( H(Router.Provider, null, hmrWrap), document.querySelector("#app"));
+ hydrate(
+ H(Router.Provider, null,
+ H(Meta.Provider, null, hmrWrap)
+ ),
+ document.querySelector("#app")
+ );
`;