| | |
| | | import micromorph from "micromorph" |
| | | import { CanonicalSlug, RelativeURL, getCanonicalSlug } from "../../util/path" |
| | | import { FullSlug, RelativeURL, getFullSlug } from "../../util/path" |
| | | |
| | | // adapted from `micromorph` |
| | | // https://github.com/natemoo-re/micromorph |
| | |
| | | return { url: new URL(href), scroll: "routerNoscroll" in a.dataset ? false : undefined } |
| | | } |
| | | |
| | | function notifyNav(url: CanonicalSlug) { |
| | | function notifyNav(url: FullSlug) { |
| | | const event: CustomEventMap["nav"] = new CustomEvent("nav", { detail: { url } }) |
| | | document.dispatchEvent(event) |
| | | } |
| | |
| | | const elementsToAdd = html.head.querySelectorAll(":not([spa-preserve])") |
| | | elementsToAdd.forEach((el) => document.head.appendChild(el)) |
| | | |
| | | notifyNav(getCanonicalSlug(window)) |
| | | notifyNav(getFullSlug(window)) |
| | | delete announcer.dataset.persist |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | createRouter() |
| | | notifyNav(getCanonicalSlug(window)) |
| | | notifyNav(getFullSlug(window)) |
| | | |
| | | if (!customElements.get("route-announcer")) { |
| | | const attrs = { |