返回 slidev
Link.vue
根目录 / packages / client / builtin / Link.vue
1 <!--
2 Create a link in the presentation
3
4 Usage:
5
6 <Link :to="5" >Go to slide 5</Link>
7
8 <Link :to="5" title="Go to slide 5" />
9 -->
10 <script setup lang="ts">
11 import { computed } from 'vue'
12 import { useNav } from '../composables/useNav'
13 import { getPrintSlideAnchorId } from '../logic/slidePath'
14 import { getSlide } from '../logic/slides'
15
16 const props = defineProps<{
17 to: number | string
18 title?: string
19 }>()
20
21 const { isPrintMode } = useNav()
22
23 const printHref = computed(() => `#${getPrintSlideAnchorId(getSlide(props.to)?.no ?? props.to)}`)
24 </script>
25
26 <template>
27 <RouterLink v-if="!isPrintMode && title" :to="String(to)" @click="($event.target as HTMLElement)?.blur()" v-html="title" />
28 <RouterLink v-else-if="!isPrintMode && !title" :to="String(to)" @click="($event.target as HTMLElement)?.blur()">
29 <slot />
30 </RouterLink>
31 <a v-else-if="isPrintMode && title" :href="printHref" v-html="title" />
32 <a v-else :href="printHref"><slot /></a>
33 </template>
34
34 lines Plain Text