Skip to content

Commit

Permalink
Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JAForbes committed Feb 15, 2024
1 parent 7196799 commit 8766d20
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions readme.md
Expand Up @@ -75,7 +75,7 @@ type State = {
instance.get(): State
```

Returns the route instance's path in its local context. Returns `undefined` if a nested route is not compatible with the current browser location pathname.
Returns the instance's path in its local context. Returns `undefined` if a nested history is not compatible with the current browser location pathname.

### `instance.go(...)`

Expand Down Expand Up @@ -118,12 +118,18 @@ Returns the complete normalized prefix of the child instance (including all pare
instance.child(options: { prefix: string, onChange?: (state: State) => void })
```

Create a nested route context. All route operations will receive/return a local pathname that does not include the `prefix` that you supply.
Create a nested istory context. All history operations will receive/return a local pathname that does not include the `prefix` that you supply.

These operations are applied directly to the history API by the child instance using the concatenated prefixes of all of its parents.

## Advanced

### Extracting variables out of paths

This library isn't a router, its just a small wrapper around the browser history API that you could build a pattern matching router on top of.

If you're looking for a pattern matching router engine: Check out [superouter](https://github.com/JAForbes/superouter)

### Path / Prefix normalization

While not strictly correct, *superhistory* removes trailing slashes as applications tend to treat `/a/b/c` and `/a/b/c/` as equivalent. By normalizing paths in this way the internal logic becomes much simpler when gluing together prefixes on nested child nodes.
Expand Down

0 comments on commit 8766d20

Please sign in to comment.