diff --git a/pkg/template.go b/pkg/template.go
index af592bf..a5fdeff 100644
--- a/pkg/template.go
+++ b/pkg/template.go
@@ -10,6 +10,7 @@ import (
"math"
"net/http"
"strconv"
+ "strings"
"time"
)
@@ -30,6 +31,12 @@ func mustRenderTemplate(wr io.Writer, r *http.Request, layout string, filename s
"currentLocale": func() string {
return locale.Language.String()
},
+ "requestURIMatches": func(uri string) bool {
+ return r.RequestURI == uri
+ },
+ "requestURIHasPrefix": func(uri string) bool {
+ return strings.HasPrefix(r.RequestURI, uri)
+ },
"companyURI": func(uri string) string {
return companyURI(company, uri)
},
diff --git a/web/static/numerus.css b/web/static/numerus.css
index 2777c9f..e44c51c 100644
--- a/web/static/numerus.css
+++ b/web/static/numerus.css
@@ -562,10 +562,12 @@ ul[role="menu"].action-menu li i[class^='ri-'] {
text-decoration: underline;
}
+body > nav a[aria-current] {
+ background-color: yellow;
+}
/* menu tauler final */
-
main > nav {
display: flex;
justify-content: space-between;
diff --git a/web/static/numerus.js b/web/static/numerus.js
index 13eadec..9f3c9c4 100644
--- a/web/static/numerus.js
+++ b/web/static/numerus.js
@@ -713,7 +713,7 @@ htmx.on('closeModal', () => {
htmx.on(document, 'alpine:init', () => {
document.body.classList.remove('filters-visible');
-
+
Alpine.data('snackbar', () => ({
show: false, toast: "", toasts: [], timeoutId: null, init() {
htmx.on('htmx:error', (error) => {
@@ -753,3 +753,19 @@ htmx.on(document, 'alpine:init', () => {
},
}));
});
+
+function updateCurrentMenuItem() {
+ const path = window.location.pathname;
+ const items = document.querySelectorAll('body > nav a');
+ items.forEach((item, i) => {
+ const matches = path === item.pathname;
+ if (matches || (i !== 0 && path.startsWith(item.pathname))) {
+ item.setAttribute('aria-current', 'page');
+ } else {
+ item.removeAttribute('aria-current');
+ }
+ });
+}
+
+htmx.on('htmx:pushedIntoHistory', updateCurrentMenuItem);
+htmx.on('htmx:replacedInHistory', updateCurrentMenuItem);
diff --git a/web/template/app.gohtml b/web/template/app.gohtml
index 170a03a..62c8f59 100644
--- a/web/template/app.gohtml
+++ b/web/template/app.gohtml
@@ -50,12 +50,12 @@