-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change Schedule link to be new custom link
This link will allow us to not care about remembering to include localePath and will correctly add the is-active class to link, regardless of the query or hash This change will be added to other links later, to avoid breaking anything major right before a push. This is the only page that will really benefit now as is.
- Loading branch information
Showing
2 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!-- | ||
This is a custom linker to deal with a deficit in the Vue Router linking system | ||
Route matching only occur as route.startsWith(link) or route === link, neither of | ||
which work correctly universally. This will apparently be addressed more generally | ||
in the future. | ||
See: https://github.com/vuejs/rfcs/pull/136 | ||
See also: https://github.com/vuejs/vue-router/issues/2040 | ||
|
||
This is also somewhat nice to centralize the localePath logic, so we don't have | ||
to type it absolutely everywhere. | ||
--> | ||
|
||
<template> | ||
<NuxtLink :to="path" :class="isActive"> | ||
<slot /> | ||
</NuxtLink> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue'; | ||
import { IsActive } from '~/types/components/is-active'; | ||
|
||
export default Vue.extend({ | ||
props: { | ||
to: { | ||
type: String, | ||
default: '', | ||
}, | ||
}, | ||
computed: { | ||
isActive(): IsActive { | ||
return { | ||
'is-active': this.$route.path === this.path, | ||
}; | ||
}, | ||
path(): string { | ||
return this.localePath(this.to); | ||
}, | ||
}, | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters