From a6e9e4cf47dc6a1a883810bb68d8a3481a8ea67a Mon Sep 17 00:00:00 2001 From: BobChao87 Date: Wed, 29 Sep 2021 00:59:45 -0700 Subject: [PATCH] Replace NuxtLink with ElementLink This allows us to have active classes on hash mapped routes for the page and the anchor links. This will also allow us to place more complex logic onto our linkings where relevant. Related to Issue #32 --- components/element/Link.vue | 7 +++++-- components/header/Cookies.vue | 4 ++-- components/header/Nav.vue | 12 ++++++------ components/homepage/Marathons.vue | 6 +++--- components/marathon/schedule/Current.vue | 4 ++-- components/marathon/schedule/Run.vue | 8 ++++---- components/marathon/sidebar/Admin.vue | 16 ++++++++-------- components/marathon/sidebar/Overview.vue | 12 ++++++------ components/marathon/sidebar/Tracker.vue | 12 ++++++------ components/widget/v1/Redirect.vue | 4 ++-- layouts/error.vue | 4 ++-- 11 files changed, 46 insertions(+), 43 deletions(-) diff --git a/components/element/Link.vue b/components/element/Link.vue index bf685473..f04a9d9d 100644 --- a/components/element/Link.vue +++ b/components/element/Link.vue @@ -30,11 +30,14 @@ export default Vue.extend({ computed: { isActive(): IsActive { return { - 'is-active': this.$route.path === this.path, + 'is-active': (this.isHash ? this.$route.hash : this.$route.path) === this.path, }; }, path(): string { - return this.localePath(this.to); + return this.isHash ? this.to : this.localePath(this.to); + }, + isHash(): boolean { + return this.to.startsWith('#'); }, }, }); diff --git a/components/header/Cookies.vue b/components/header/Cookies.vue index 16124736..57b9e1c9 100644 --- a/components/header/Cookies.vue +++ b/components/header/Cookies.vue @@ -11,9 +11,9 @@ - + {{ $t('navbar.about') }} - + diff --git a/components/header/Nav.vue b/components/header/Nav.vue index 8d21e5ce..d89c6e4d 100644 --- a/components/header/Nav.vue +++ b/components/header/Nav.vue @@ -1,12 +1,12 @@