public/components/StoryStatBox.vue

56 lines
1.4 KiB
Vue
Raw Normal View History

<script setup lang="ts">
import { type StoryParsedContent } from "@/shared/types";
2022-08-10 17:22:08 -04:00
import { calcReadingTime, getPrettyDate } from "@/shared/metadata";
2022-08-08 18:41:29 -04:00
2022-08-09 15:37:32 -04:00
const docs = await queryContent<StoryParsedContent>("/stories")
2022-08-08 18:41:29 -04:00
.sort({ date: 1 })
.where({ _draft: false })
.find();
2022-08-09 15:37:32 -04:00
const latest = docs.at(-1) as StoryParsedContent;
2022-08-08 18:41:29 -04:00
2022-08-10 17:22:08 -04:00
const prettyDate = getPrettyDate(latest);
</script>
<template>
2022-08-09 15:37:32 -04:00
<div class="prose dark:prose-invert flex">
2022-08-09 16:25:23 -04:00
<HomeStatBox
:href="latest._path"
color="lightgreen"
darkcolor="#2c8a2c"
title="Latest story"
>
2022-08-08 18:41:29 -04:00
<h2 class="m-0 mt-4 mb-1">{{ latest.title }}</h2>
2022-08-09 16:25:23 -04:00
<p class="text-sm text-gray-500 dark:text-gray-400 m-0">
2022-08-10 16:31:25 -04:00
{{ prettyDate }} · {{ calcReadingTime(latest).words.total }} words
2022-08-08 18:41:29 -04:00
</p>
<div class="tag-list mt-1">
<Tag
v-for="(tag, index) in latest.tags"
:key="index"
2022-08-10 16:31:25 -04:00
:dest="`/tags/stories/${tag}`"
2022-08-08 18:41:29 -04:00
>
{{ tag }}
</Tag>
</div>
<ContentRenderer
tag="article"
:value="latest"
:excerpt="true"
2022-08-10 16:31:25 -04:00
class="text-gray-600 dark:text-gray-300 text-base m-0 mt-5 text-ellipsis"
2022-08-08 18:41:29 -04:00
>
<ContentRendererMarkdown :value="latest" :excerpt="true" />
<template #empty>
<p>No description found.</p>
</template>
</ContentRenderer>
</HomeStatBox>
</div>
</template>
2022-08-08 18:41:29 -04:00
<style scoped>
2022-08-09 15:54:17 -04:00
h2 {
2022-08-09 21:12:49 -04:00
overflow-wrap: break-word;
2022-08-09 15:54:17 -04:00
}
2022-08-08 18:41:29 -04:00
</style>