WebIndex/components/card/ArticleCard.vue

45 lines
1.2 KiB
Vue
Raw Normal View History

2024-11-17 11:45:08 +08:00
<script lang="ts" setup>
2025-01-13 21:51:37 +08:00
import { computed } from 'vue'
2024-11-17 11:45:08 +08:00
const props = defineProps<{
2025-01-13 21:51:37 +08:00
post: IPost
}>(),
2024-11-17 11:45:08 +08:00
2025-01-13 21:51:37 +08:00
pid = useAsyncData('pid', async () => (Math.floor(Math.random() * (7 - 1 + 1)) + 1).toString()),
2025-01-13 21:51:37 +08:00
thumbUrl = computed(() => props.post.fields.thumb.value),
2024-11-17 11:45:08 +08:00
2025-01-13 21:51:37 +08:00
randomId = computed(() => pid.data.value!)
2024-11-17 11:45:08 +08:00
</script>
<template>
2025-01-13 21:51:37 +08:00
<nuxt-link
:title="post.title"
class="container relative overflow-hidden rounded-2xl bg-white transition-all duration-300 ease-in-out h-[31rem] hover:-translate-y-2 hover:cursor-pointer hover:shadow"
:to="{ name: 'article-cid', params: { cid: post.cid } }"
>
2024-11-17 11:45:08 +08:00
<!-- 图片 -->
2025-01-13 01:03:16 +08:00
<div class="relative">
<!-- 渐变 -->
2025-01-13 21:51:37 +08:00
<div class="absolute top-0 right-0 bottom-0 left-0 bg-gradient-to-t from-white" />
<img
v-if="thumbUrl"
:src="thumbUrl"
alt=""
class="aspect-video w-full h-auto object-cover object-center"
>
<card-article-default-image :id="randomId" />
2024-11-17 11:45:08 +08:00
</div>
<!-- 文字部分 -->
2025-01-13 01:03:16 +08:00
<div class="px-5">
<!-- 标题 -->
<h4 class="text-2xl font-bold">{{ post.title }}</h4>
<p class="mt-4 text-lg px-1 text-gray-700">{{ post.digest }}</p>
2024-11-17 11:45:08 +08:00
</div>
2024-12-02 20:00:21 +08:00
</nuxt-link>
2024-11-17 11:45:08 +08:00
</template>
<style scoped>
2025-01-13 21:51:37 +08:00
</style>