mirror of
https://github.com/srid/ema.git
synced 2024-11-29 09:25:14 +03:00
Handle switching local anchors
This commit is contained in:
parent
74557c90ee
commit
b47fddd2cf
@ -2,7 +2,7 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
- Handle URL anchors (#83)
|
||||
- Better handling of URL anchors (#83; #87)
|
||||
- Fix bug in `Ex02_Basic.hs` (wasn't generating HTML files)
|
||||
- Fix `runEmaPure` not generating routes
|
||||
- Multisite
|
||||
|
@ -337,8 +337,15 @@ wsClientJS =
|
||||
const origin = e.target.closest("a");
|
||||
if (origin) {
|
||||
if (window.location.host === origin.host && origin.getAttribute("target") != "_blank") {
|
||||
switchRoute(origin.pathname, origin.hash);
|
||||
e.preventDefault();
|
||||
if (origin.getAttribute("href").startsWith("#")) {
|
||||
// Switching to local anchor
|
||||
window.history.pushState({}, "", window.location.pathname + origin.hash);
|
||||
e.preventDefault();
|
||||
}else{
|
||||
// Switching to another route
|
||||
switchRoute(origin.pathname, origin.hash);
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user