public/components/PostPreviewCard.vue

58 lines
1.8 KiB
Vue
Raw Normal View History

2022-08-10 16:31:25 -04:00
<script setup lang="ts">
2023-05-24 12:25:31 -04:00
import type { AnyParsedContent } from "@/shared/types";
import { calcReadingTime } from "@/shared/metadata";
2023-11-19 01:19:43 -05:00
import { SpecialTags } from "@/data/specialTags";
import IconStar from "@/assets/images/star.svg?component";
2022-08-10 16:31:25 -04:00
const props = defineProps<{
2023-05-24 12:25:31 -04:00
post: AnyParsedContent;
2022-08-10 16:31:25 -04:00
type: "stories" | "blog";
highlighttags?: string[];
}>();
const readingTime = calcReadingTime(props.post);
2022-08-10 16:31:25 -04:00
const descText =
props.type === "stories"
2022-08-10 16:31:25 -04:00
? `${readingTime.words.total} words`
: `${readingTime.minutes} min read`;
</script>
<template>
<div
2023-05-24 12:33:50 -04:00
class="break-words max-w-full rounded-lg p-4 shadow-md border border-2 border-gray-300 dark:border-gray-600"
>
2023-11-19 01:19:43 -05:00
<h3 class="m-0 flex items-center gap-1.5">
<IconStar v-if="post.tags.includes('featured')" class="fill-yellow-500 outline-none" />
2022-08-10 16:31:25 -04:00
<a
:href="post._path"
class="no-underline text-left text-2xl sm:text-2xl font-bold hover:text-blue-700 dark:hover:text-blue-400 leading-tight transition"
>
{{ post.title }}
</a>
</h3>
<p class="my-1 text-sm"><Date :doc="post" /> · {{ descText }}</p>
2022-08-10 16:31:25 -04:00
<div class="flex flex-wrap">
2023-11-19 01:19:43 -05:00
<template v-for="(tag, index) in post.tags" :key="index">
2022-08-10 16:31:25 -04:00
<Tag
:dest="`/tags/${type}/${tag}`"
:name="tag"
2022-08-10 16:31:25 -04:00
:highlight="highlighttags?.includes(tag)"
2023-11-19 01:19:43 -05:00
v-if="!SpecialTags.includes(tag)"
/>
2023-11-19 01:19:43 -05:00
</template>
2022-08-10 16:31:25 -04:00
</div>
<ContentRenderer :value="post" :excerpt="true" tag="section">
2022-08-10 16:31:25 -04:00
<template #empty>No excerpt available.</template>
</ContentRenderer>
2022-08-10 17:26:37 -04:00
<!--<p v-if="!post.nopreview" class="m-0"></p>-->
<div class="text-right" v-if="!post.nopreview">
2022-08-10 16:31:25 -04:00
<a
:href="post._path"
class="no-underline hover:underline font-semibold text-blue-700 dark:text-blue-400"
>
Continue reading
</a>
</div>
</div>
</template>