Skip to content

Commit

Permalink
fix anchor navigation (#87)
Browse files Browse the repository at this point in the history
Co-authored-by: rafapaezbas <rafa@holepunch.com>
  • Loading branch information
2 people authored and davidmarkclements committed Mar 8, 2024
1 parent 8e59393 commit fff5fc7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion building-blocks/hyperdrive.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Notable features include:

* Uses Hyperbee internally for storing file metadata
* Major API simplification. Instead of mirroring POSIX APIs, the new API better captures the core requirements of P2P file transfer.
* Auxiliary tools, [`localdrive`](./helpers/localdrive.md) and [`mirrordrive`](./helpers/mirrordrive.md), that streamline import/export flows and make it easy to mirror drives to and from the local filesystem.
* Auxiliary tools, [`localdrive`](../helpers/localdrive.md) and [`mirrordrive`](../helpers/mirrordrive.md), that streamline import/export flows and make it easy to mirror drives to and from the local filesystem.

> [GitHub (Hyperdrive)](https://github.com/holepunchto/hyperdrive)
Expand Down
4 changes: 3 additions & 1 deletion lib/app-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ customElements.define('app-router', class AppRouter extends HTMLElement {
super()
this.routes = {}
this.page = null
this.anchor = null
}

unload () {
for (const element of Object.values(this.routes)) element?.unload && element.unload()
}

async load (pathname = '/', opts = {}) {
if (this.page === pathname) return
if (this.page === pathname && this.anchor === opts.anchor) return
this.page = pathname
this.anchor = opts.anchor
for (const [route, element] of Object.entries(this.routes)) {
if (pathname.startsWith(route)) {
const page = pathname.slice(route.length) || '/'
Expand Down

0 comments on commit fff5fc7

Please sign in to comment.