返回 slidev
LinkCard.vue
根目录 / docs / .vitepress / theme / components / LinkCard.vue
1 <script setup lang="ts">
2 import { withBase } from 'vitepress'
3 import { computed } from 'vue'
4 import { resolveLink } from '../../utils'
5
6 const props = defineProps<{
7 link: string
8 }>()
9
10 const resolved = computed(() => resolveLink(props.link))
11 </script>
12
13 <template>
14 <div class="sr-only">
15 {{ resolved.title }}
16 </div>
17 <ClientOnly>
18 <a class="link-card" :href="withBase(resolved.url)">
19 <div class="title">
20 <div>{{ resolved.title }}</div>
21 <div flex-grow />
22 <div flex gap-1>
23 <FeatureTag v-for="tag in resolved.tags" :key="tag" :tag />
24 </div>
25 </div>
26 <div class="description">
27 {{ resolved.descripton }}
28 </div>
29 </a>
30 </ClientOnly>
31 </template>
32
33 <style scoped>
34 .link-card {
35 --uno: 'block my-4 pl-8 pr-6 py-6 rounded-lg bg-$vp-c-bg-soft flex flex-col gap-2';
36 border: 2px solid var(--vp-c-bg-soft);
37 transition:
38 color 0.5s,
39 background-color 0.5s;
40 text-decoration: none;
41 }
42
43 .link-card:hover {
44 border-color: var(--vp-c-brand-soft);
45 transition: border-color 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
46 }
47
48 .title {
49 font-size: 18px;
50 line-height: 1.4;
51 letter-spacing: -0.02em;
52 display: flex;
53 color: var(--vp-c-brand-1);
54 }
55
56 .description {
57 margin-bottom: 0;
58 color: var(--vp-c-text-2);
59 transition: color 0.5s;
60 }
61 </style>
62
62 lines Plain Text