2024-01-05 12:14:38 +00:00
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import type { DefaultTheme } from 'vitepress/theme'
|
2026-02-16 13:45:45 +00:00
|
|
|
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'
|
|
|
|
|
|
2026-02-16 13:45:45 +00:00
|
|
|
const props = defineProps<{
|
2024-01-05 12:14:38 +00:00
|
|
|
item: DefaultTheme.NavItemWithLink
|
|
|
|
|
}>()
|
|
|
|
|
|
2026-02-16 13:45:45 +00:00
|
|
|
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
|
2026-02-16 13:45:45 +00:00
|
|
|
:class="{ VPNavScreenMenuLink: true, active: isActiveLink }"
|
|
|
|
|
:href
|
2024-01-05 12:14:38 +00:00
|
|
|
:target="item.target"
|
|
|
|
|
:rel="item.rel"
|
2026-02-11 16:20:26 +00:00
|
|
|
:no-icon="item.noIcon"
|
2024-01-05 12:14:38 +00:00
|
|
|
@click="closeScreen"
|
|
|
|
|
>
|
2026-02-11 16:20:26 +00:00
|
|
|
<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);
|
2026-02-11 16:20:26 +00:00
|
|
|
transition:
|
|
|
|
|
border-color 0.25s,
|
|
|
|
|
color 0.25s;
|
2024-01-05 12:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.VPNavScreenMenuLink:hover {
|
|
|
|
|
color: var(--vp-c-brand-1);
|
|
|
|
|
}
|
2026-02-16 13:45:45 +00:00
|
|
|
|
|
|
|
|
.VPNavScreenMenuLink.active {
|
|
|
|
|
color: var(--vp-c-brand-1);
|
|
|
|
|
}
|
2024-01-05 12:14:38 +00:00
|
|
|
</style>
|