Warp/node_modules/vitepress/dist/client/theme-default/components/VPNavScreenMenuLink.vue

67 lines
1.4 KiB
Vue
Raw Normal View History

2024-01-05 12:14:38 +00:00
<script lang="ts" setup>
import type { DefaultTheme } from 'vitepress/theme'
import { computed, inject } from 'vue'
import { useData } from '../composables/data'
import { isActive } from '../../shared'
import { navInjectionKey } from '../composables/nav'
2024-01-05 12:14:38 +00:00
import VPLink from './VPLink.vue'
const props = defineProps<{
2024-01-05 12:14:38 +00:00
item: DefaultTheme.NavItemWithLink
}>()
const { page } = useData()
const href = computed(() =>
typeof props.item.link === 'function'
? props.item.link(page.value)
: props.item.link
)
const isActiveLink = computed(() =>
isActive(
page.value.relativePath,
props.item.activeMatch || href.value,
!!props.item.activeMatch
)
)
const { closeScreen } = inject(navInjectionKey)!
2024-01-05 12:14:38 +00:00
</script>
<template>
<VPLink
:class="{ VPNavScreenMenuLink: true, active: isActiveLink }"
:href
2024-01-05 12:14:38 +00:00
:target="item.target"
:rel="item.rel"
:no-icon="item.noIcon"
2024-01-05 12:14:38 +00:00
@click="closeScreen"
>
<span v-html="item.text"></span>
2024-01-05 12:14:38 +00:00
</VPLink>
</template>
<style scoped>
.VPNavScreenMenuLink {
display: block;
border-bottom: 1px solid var(--vp-c-divider);
padding: 12px 0 11px;
line-height: 24px;
font-size: 14px;
font-weight: 500;
color: var(--vp-c-text-1);
transition:
border-color 0.25s,
color 0.25s;
2024-01-05 12:14:38 +00:00
}
.VPNavScreenMenuLink:hover {
color: var(--vp-c-brand-1);
}
.VPNavScreenMenuLink.active {
color: var(--vp-c-brand-1);
}
2024-01-05 12:14:38 +00:00
</style>