From 540765a78042ae21f3ea6be244d25145f40addab Mon Sep 17 00:00:00 2001 From: rafapaezbas <15270736+rafapaezbas@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:49:24 +0100 Subject: [PATCH] fix anchor navigation (#87) Co-authored-by: rafapaezbas --- building-blocks/hyperdrive.md | 2 +- lib/app-router.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/building-blocks/hyperdrive.md b/building-blocks/hyperdrive.md index 0efd572..cebb883 100644 --- a/building-blocks/hyperdrive.md +++ b/building-blocks/hyperdrive.md @@ -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) diff --git a/lib/app-router.js b/lib/app-router.js index a9b155b..de0c659 100644 --- a/lib/app-router.js +++ b/lib/app-router.js @@ -4,6 +4,7 @@ customElements.define('app-router', class AppRouter extends HTMLElement { super() this.routes = {} this.page = null + this.anchor = null } unload () { @@ -11,8 +12,9 @@ customElements.define('app-router', class AppRouter extends HTMLElement { } 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) || '/'