Skip to content

Commit

Permalink
RouterComponent default pathStore now defaults to window.loc.pathname
Browse files Browse the repository at this point in the history
  • Loading branch information
LankyMoose committed Sep 2, 2023
1 parent 5f916cd commit c8f7a95
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion package/lib/src/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export class RouteComponent extends Component {
}

export class RouterComponent extends Component {
static pathStore = new Signal<string>("/")
static pathStore = new Signal<string>(
Cinnabun.isClient ? window.location.pathname : "/"
)

constructor(
store: Signal<string> = RouterComponent.pathStore,
Expand Down
4 changes: 2 additions & 2 deletions sandbox/docs/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export const App = () => {
<Header />
<main>
<Router store={pathStore}>
<Route path="/" component={<div>Home</div>} />
<Route path="/docs" component={Docs} />
<Route path="/cinnabun" component={<div>Home</div>} />
<Route path="/cinnabun/docs" component={Docs} />
</Router>
</main>
<footer></footer>
Expand Down

0 comments on commit c8f7a95

Please sign in to comment.