diff --git a/libs/embeds/src/link.ts b/libs/embeds/src/link.ts index 5b28aaf..60bf404 100644 --- a/libs/embeds/src/link.ts +++ b/libs/embeds/src/link.ts @@ -31,7 +31,9 @@ export class LinkEmbed extends HTMLElement { if (_link.dataset?.href?.startsWith('/') && !!window.router) { e.preventDefault() const route = window.router.resolve({ path: _link.dataset.href }) - window.router.push(route) + if (route.path !== window.router.currentRoute.value.path) { + window.router.push(route) + } } }) this._observers.href = { @@ -40,6 +42,12 @@ export class LinkEmbed extends HTMLElement { const { element } = this._observers.href element!.setAttribute('href', newVal) element!.dataset.href = newVal + if (!!window.router) { + const route = window.router.resolve({ path: newVal }) + if (route.path === window.router.currentRoute.value.path) { + element!.classList.add('current-route') + } + } }, } this._observers.target = { diff --git a/projects/frontend/src/components/shared/header-link.vue b/projects/frontend/src/components/shared/header-link.vue index b5f57d7..f9e64df 100644 --- a/projects/frontend/src/components/shared/header-link.vue +++ b/projects/frontend/src/components/shared/header-link.vue @@ -1,8 +1,11 @@ + +