diff options
| -rw-r--r-- | backend/templates/base.html | 2 | ||||
| -rw-r--r-- | frontend/index.ts | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/backend/templates/base.html b/backend/templates/base.html index f0ae617..e56341b 100644 --- a/backend/templates/base.html +++ b/backend/templates/base.html @@ -24,7 +24,7 @@ <meta name="twitter:description" content="{{ .Description }}" /> <meta name="twitter:image" content="{{ fullStatic .Image }}" /> </head> -<body> +<body hx-push-url="true"> <header> <img src="{{ static .Logo.Header }}" alt="Logo"> <nav> 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 = "« " + quote + " »" - window.history.pushState({}, "", e.detail.pathInfo.finalRequestPath) setupAnchors() }) |
