aboutsummaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authorWilliam Hergès <william@herges.fr>2025-10-04 20:07:12 +0200
committerWilliam Hergès <william@herges.fr>2025-10-04 20:07:12 +0200
commitad62bd3ed2660d0691aeff1ecb11c5997f901a75 (patch)
tree78cde0d57dfb5f22a2270e2cd5d928b2d763fe36 /frontend
parent52e85e838e7bbd7fa8860e175701303c81db9217 (diff)
fix(frontend): use htmx history instead of custom implementation to have history working
Diffstat (limited to 'frontend')
-rw-r--r--frontend/index.ts4
1 files changed, 3 insertions, 1 deletions
diff --git a/frontend/index.ts b/frontend/index.ts
index ee1e7ae..9babe4a 100644
--- a/frontend/index.ts
+++ b/frontend/index.ts
@@ -1,5 +1,7 @@
import htmx from "htmx.org";
+htmx.config.historyRestoreAsHxRequest = false;
+
function setupAnchors() {
document.querySelectorAll("a").forEach(e => {
if (!e.href.startsWith(window.location.origin) && /https?:\/\//.test(e.href)) {
@@ -17,12 +19,12 @@ function setupAnchors() {
// updating history and window title
document.addEventListener("htmx:afterSettle", e => {
+ if (e.detail.xhr === undefined) return
const title = e.detail.xhr.getResponseHeader("Updated-Title")
if (title?.length !== 0) document.title = title
const quote = e.detail.xhr.getResponseHeader("Updated-Quote")
if (quote?.length !== 0)
document.querySelector("#quote")!.innerHTML = "«&thinsp;" + quote + "&thinsp;»"
- window.history.pushState({}, "", e.detail.pathInfo.finalRequestPath)
setupAnchors()
})