aboutsummaryrefslogtreecommitdiff
path: root/docs/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/index.html')
-rw-r--r--docs/index.html23
1 files changed, 22 insertions, 1 deletions
diff --git a/docs/index.html b/docs/index.html
index 0e7b438..82c2697 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -36,7 +36,12 @@
<!-- End Single Page Apps for GitHub Pages -->
<script type="module">
- import { main, Route, OnRouteChange } from "./src/app.gleam";
+ import {
+ main,
+ Route,
+ OnRouteChange,
+ OnRouteHover,
+ } from "./src/app.gleam";
const strip_base = (path) =>
`/${path.slice(import.meta.env.BASE_URL.length)}`;
@@ -79,6 +84,22 @@
}
});
+ document.addEventListener("mouseover", (e) => {
+ let target = e.target;
+
+ while (target) {
+ if (target === document.body) return;
+ if (target.tagName === "A") {
+ const url = new URL(target.href);
+ if (url.origin !== window.location.origin) return;
+ const route = new Route(strip_base(url.pathname), url.hash);
+ return void dispatch(new OnRouteHover(route));
+ }
+
+ target = target.parentNode;
+ }
+ });
+
// This lets us listen to the back and forward buttons in the browser
// and trigger our app's routing.
window.addEventListener("popstate", () => {