Files
Library/node_modules/vitepress/dist/client/theme-default/components/VPNavBarMenuLink.vue

61 lines
1.2 KiB
Vue
Raw Normal View History

2026-01-09 23:05:52 -05:00
<script lang="ts" setup>
import type { DefaultTheme } from 'vitepress/theme'
import { computed } from 'vue'
import { useData } from '../composables/data'
import { isActive } from '../../shared'
import VPLink from './VPLink.vue'
const props = defineProps<{
item: DefaultTheme.NavItemWithLink
}>()
const { page } = useData()
const href = computed(() =>
typeof props.item.link === 'function'
? props.item.link(page.value)
: props.item.link
)
</script>
<template>
<VPLink
:class="{
VPNavBarMenuLink: true,
active: isActive(
page.relativePath,
item.activeMatch || href,
!!item.activeMatch
)
}"
:href
:target="item.target"
:rel="item.rel"
:no-icon="item.noIcon"
tabindex="0"
>
<span v-html="item.text"></span>
</VPLink>
</template>
<style scoped>
.VPNavBarMenuLink {
display: flex;
align-items: center;
padding: 0 12px;
line-height: var(--vp-nav-height);
font-size: 14px;
font-weight: 500;
color: var(--vp-c-text-1);
transition: color 0.25s;
}
.VPNavBarMenuLink.active {
color: var(--vp-c-brand-1);
}
.VPNavBarMenuLink:hover {
color: var(--vp-c-brand-1);
}
</style>