mirror of
https://github.com/aljazceru/pear-docs.git
synced 2025-12-17 14:34:19 +01:00
fix anchor navigation (#87)
Co-authored-by: rafapaezbas <rafa@holepunch.com>
This commit is contained in:
@@ -6,7 +6,7 @@ Notable features include:
|
|||||||
|
|
||||||
* Uses Hyperbee internally for storing file metadata
|
* 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.
|
* 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)
|
> [GitHub (Hyperdrive)](https://github.com/holepunchto/hyperdrive)
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ customElements.define('app-router', class AppRouter extends HTMLElement {
|
|||||||
super()
|
super()
|
||||||
this.routes = {}
|
this.routes = {}
|
||||||
this.page = null
|
this.page = null
|
||||||
|
this.anchor = null
|
||||||
}
|
}
|
||||||
|
|
||||||
unload () {
|
unload () {
|
||||||
@@ -11,8 +12,9 @@ customElements.define('app-router', class AppRouter extends HTMLElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async load (pathname = '/', opts = {}) {
|
async load (pathname = '/', opts = {}) {
|
||||||
if (this.page === pathname) return
|
if (this.page === pathname && this.anchor === opts.anchor) return
|
||||||
this.page = pathname
|
this.page = pathname
|
||||||
|
this.anchor = opts.anchor
|
||||||
for (const [route, element] of Object.entries(this.routes)) {
|
for (const [route, element] of Object.entries(this.routes)) {
|
||||||
if (pathname.startsWith(route)) {
|
if (pathname.startsWith(route)) {
|
||||||
const page = pathname.slice(route.length) || '/'
|
const page = pathname.slice(route.length) || '/'
|
||||||
|
|||||||
Reference in New Issue
Block a user