diff --git a/example/app.tsx b/example/app.tsx
index 405429d..d6bdc70 100644
--- a/example/app.tsx
+++ b/example/app.tsx
@@ -13,6 +13,12 @@ export default ()=>
Title!!
subtitle
+
+
+ About Us
+
+ lol/idk
+
;
};
diff --git a/example/deep/component.tsx b/example/deep/component.tsx
index 5bed3d8..124ecfc 100644
--- a/example/deep/component.tsx
+++ b/example/deep/component.tsx
@@ -12,6 +12,6 @@ export default ()=>
Route is: {routeGet.Path.toString()}
Component!!!
- a link
+ a link
;
};
\ No newline at end of file
diff --git a/lib/iso.tsx b/lib/iso.tsx
index 8333a1f..fa6a91a 100644
--- a/lib/iso.tsx
+++ b/lib/iso.tsx
@@ -97,4 +97,58 @@ export const Router = {
{
return React.useContext(Router.Context);
}
-};
\ No newline at end of file
+};
+
+type SwitchContext = {depth:number, keys:Record};
+export const SwitchContext = React.createContext({depth:0, keys:{}} as SwitchContext);
+export const Switch =({children}:{children:typeof React.Children})=>
+{
+ const contextSelection = React.useContext(SwitchContext);
+ const [contextRoute] = Router.Consumer();
+ const routeSegment = contextRoute.Path.slice(contextSelection.depth);
+ const checkChild =(inChild:{props:{value?:string}})=>
+ {
+ if(inChild?.props?.value)
+ {
+ const parts = inChild.props.value.split("/");
+ if(parts.length > routeSegment.length)
+ {
+ return false;
+ }
+
+ const output:SwitchContext = {depth:contextSelection.depth+parts.length, keys:{}};
+ for(let i=0; iRoute Rendred!{child}
+ }
+ }
+ return null;
+};
+export const Case =({children, value}:{children:typeof React.Children, value?:string})=>
+{
+ return <>{children}>;
+};
+export const useRouteVars =()=> React.useContext(SwitchContext).keys;
\ No newline at end of file
diff --git a/server.tsx b/server.tsx
index 06c98d5..e6613ff 100644
--- a/server.tsx
+++ b/server.tsx
@@ -35,7 +35,7 @@ const Transpileable =(inFilePath:string):boolean=>
};
const Transpile =async(inCode:string, inKey:string):Promise=>
{
- const transpile = await ESBuild.transform(inCode, { loader: "tsx", sourcemap: "inline", minify:false });
+ const transpile = await ESBuild.transform(inCode, { loader: "tsx", sourcemap: "inline", minify:false});
Transpiled.set(inKey, transpile.code);
return transpile.code;
};