Skip to content

Commit

Permalink
chore(pages): set title from htmx's response
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaraa committed May 26, 2024
1 parent 6a56fed commit 1f8fad3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion static/js/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ window.addEventListener("load", () => {
});

document.addEventListener("htmx:afterRequest", function (e) {
console.log("lol", e);
if (!!e.detail && !!e.detail.xhr) {
const newTitle = e.detail.xhr.getResponseHeader("HX-Title");
if (newTitle) {
document.title = newTitle + " - DankMuzikk";
}
}
});

window.Router = { updateActiveNavLink };

0 comments on commit 1f8fad3

Please sign in to comment.