Skip to content

Commit

Permalink
highlight archive on uncertainty view
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr0nox committed Apr 24, 2024
1 parent 21e291e commit d6de8d5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions UncertaintySourceArchive/src/components/NavBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
name: 'Archive'
}"
:alternative-link-names="['uncertainty']"
/>
<NavBarComponent
:link="{
Expand Down
16 changes: 14 additions & 2 deletions UncertaintySourceArchive/src/components/NavBarComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
<script setup lang="ts">
import { router } from '@/router'
import type { PropType } from 'vue'
import { RouterLink, type RouteLocationNamedRaw, type RouteParamsRaw } from 'vue-router'
import {
RouterLink,
type RouteLocationNamedRaw,
type RouteParamsRaw,
type RouteRecordName
} from 'vue-router'
type Route = {
link: RouteLocationNamedRaw
Expand All @@ -42,12 +47,19 @@ const props = defineProps({
type: Array as PropType<Route[]>,
required: false,
default: () => []
},
alternativeLinkNames: {
type: Array<RouteRecordName>,
required: false,
default: () => []
}
})
function isCurrentRoute(route?: Route): boolean {
const link = route ?? props.link
const sameName = router.currentRoute.value.name == link.link.name
const sameName =
router.currentRoute.value.name == link.link.name ||
props.alternativeLinkNames.includes(router.currentRoute.value.name ?? '')
if (link.link.params != undefined) {
return (
sameName &&
Expand Down

0 comments on commit d6de8d5

Please sign in to comment.