Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix anchor navigation #87

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading