diff --git a/app.tsx b/app.tsx index 411929b..e5ececd 100644 --- a/app.tsx +++ b/app.tsx @@ -1,10 +1,4 @@ -import {Route, useRoute} from ">able/iso-router.tsx"; - -const Tracer =()=> -{ - const {nestedDepth, pathIndex, blocked} = useRoute(); - return
Depth: {nestedDepth}, Index:{pathIndex}, Match:{blocked.value}
-} +import {Route, useRoute, Meta} from ">able/iso-router.tsx"; export default ()=>

App

@@ -13,6 +7,7 @@ export default ()=>
About 404 +

home page!

About page!

more!

- couldnt find it + + + couldnt find it +

404 :(

; \ No newline at end of file diff --git a/iso-router.tsx b/iso-router.tsx index a050f50..8ad75e0 100644 --- a/iso-router.tsx +++ b/iso-router.tsx @@ -2,17 +2,40 @@ import * as Signal from "@preact/signals"; import * as React from "react"; ///////// Metas -type MetaFields = {title?:string, description?:string}; -type MetaRecord = MetaFields&{id:string} +type MetaFields = {title?:string, description?:string} +type MetaRecord = MetaFields&{id:string, baked?:MetaFields} const Stack = [] as MetaRecord[]; -const StackPush =(m:MetaRecord)=> {Stack.push(m); Update();} +const StackPush =(m:MetaRecord)=> +{ + m.baked = {...(Stack.at(-1)?.baked || {}), ...m}; + /* + const previous = Stack.at(-1)?.baked; + if(previous) + { + Object.entries(previous).forEach(([key, prevValue], i)=> + { + const fields = m.baked as Record; + const currValue = fields[key]; + + if(currValue) + { + + } + + fields[key] = prevValue + concat + currValue; + }) + } + */ + Stack.push(m); Update(); +} const StackPop =(id:string)=> {Stack.splice(Stack.findIndex( item => item.id === id ), 1); Update();} -const Update =()=> document.title = Stack[Stack.length-1]?.title || "---"; +const Update =()=> document.title = Stack.at(-1)?.baked?.title || "---"; Update(); export const useMeta=(fields:MetaFields)=> { const id = React.useId(); React.useEffect(()=>{ + StackPush({...fields, id}); return ()=>StackPop(id); }, []); @@ -20,7 +43,6 @@ export const useMeta=(fields:MetaFields)=> export const Meta =(props:MetaFields)=> { useMeta(props); return null; } - //////// Router type RouteContextData = { /** Current nested depth of the router */ nestedDepth:number,