fix: nav menu link don't show active status (#680)

Co-authored-by: Kia King Ishii <kia.king.08@gmail.com>
pull/681/head
Percy Ma 2 years ago committed by GitHub
parent ae7c255aea
commit 1db3730a48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,13 +1,21 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useData } from 'vitepress'
import { isActive } from '../support/utils'
import VPLink from './VPLink.vue' import VPLink from './VPLink.vue'
defineProps<{ defineProps<{
item: any item: any
}>() }>()
const { page } = useData()
</script> </script>
<template> <template>
<VPLink class="VPMenuLink" :href="item.link"> <VPLink
class="VPMenuLink"
:class="{ active: isActive(page.relativePath, item.activeMatch || item.link) }"
:href="item.link"
>
{{ item.text }} {{ item.text }}
</VPLink> </VPLink>
</template> </template>
@ -33,4 +41,8 @@ defineProps<{
.dark .VPMenuLink:hover { .dark .VPMenuLink:hover {
background-color: var(--vp-c-bg-soft); background-color: var(--vp-c-bg-soft);
} }
.VPMenuLink.active {
color: var(--vp-c-brand);
}
</style> </style>

Loading…
Cancel
Save