2022-07-22 17:16:27 -04:00
|
|
|
<script setup lang="ts">
|
2022-08-10 12:00:48 -04:00
|
|
|
import type { StoryParsedContent } from "@/shared/types";
|
2022-08-10 13:14:48 -04:00
|
|
|
import dayjs from "dayjs";
|
|
|
|
import utc from "dayjs/plugin/utc.js";
|
|
|
|
|
|
|
|
dayjs.extend(utc);
|
2022-08-10 12:00:48 -04:00
|
|
|
|
2022-08-07 11:37:29 -04:00
|
|
|
useTitle("Stories");
|
2022-08-10 12:00:48 -04:00
|
|
|
|
2022-08-10 13:14:48 -04:00
|
|
|
// TODO: paginate stories
|
2022-08-10 12:00:48 -04:00
|
|
|
const docs = await queryContent<StoryParsedContent>("/stories")
|
|
|
|
.sort({ date: 1 })
|
|
|
|
.where({ _draft: false })
|
|
|
|
.find();
|
2022-08-10 13:14:48 -04:00
|
|
|
|
|
|
|
const getPrettyDate = (story: StoryParsedContent) => {
|
|
|
|
const date = dayjs(story.date).utc();
|
|
|
|
return date.format("DD MMM YYYY");
|
|
|
|
};
|
2022-07-22 17:16:27 -04:00
|
|
|
</script>
|
|
|
|
|
2022-08-10 11:05:20 -04:00
|
|
|
<template>
|
2022-08-10 13:27:37 -04:00
|
|
|
<main
|
|
|
|
class="flex flex-col grow prose dark:prose-invert max-w-3xl gap-6 transition"
|
|
|
|
>
|
|
|
|
<h1 class="mb-0">Stories</h1>
|
|
|
|
<div
|
|
|
|
class="story-card p-4 pb-2"
|
|
|
|
v-for="(story, index) in docs"
|
|
|
|
:key="index"
|
|
|
|
>
|
2022-08-10 13:41:58 -04:00
|
|
|
<h3 class="m-0">
|
|
|
|
<a
|
|
|
|
:href="story._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"
|
|
|
|
>
|
|
|
|
{{ story.title }}</a
|
2022-08-10 13:14:48 -04:00
|
|
|
>
|
2022-08-10 13:41:58 -04:00
|
|
|
</h3>
|
2022-08-10 13:14:48 -04:00
|
|
|
<p class="my-1 text-sm">
|
|
|
|
{{ getPrettyDate(story) }} · {{ story.readingTime.text }}
|
|
|
|
</p>
|
|
|
|
<div class="flex flex-wrap">
|
|
|
|
<Tag
|
|
|
|
:dest="`/stories/tags/${tag}`"
|
|
|
|
v-for="(tag, index) in story.tags"
|
|
|
|
:key="index"
|
|
|
|
>
|
|
|
|
{{ tag }}
|
|
|
|
</Tag>
|
|
|
|
</div>
|
|
|
|
<p class="mb-1">{{ story.description }} ...</p>
|
|
|
|
<div class="text-right">
|
|
|
|
<a
|
|
|
|
:href="story._path"
|
2022-08-10 13:27:37 -04:00
|
|
|
class="no-underline hover:underline font-semibold text-blue-700 dark:text-blue-400"
|
2022-08-10 13:14:48 -04:00
|
|
|
>
|
|
|
|
Continue reading →
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-08-10 12:00:48 -04:00
|
|
|
</main>
|
2022-08-10 11:05:20 -04:00
|
|
|
</template>
|
2022-08-10 13:14:48 -04:00
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.story-card {
|
|
|
|
border: 0.1rem solid gray;
|
|
|
|
max-width: 100%;
|
|
|
|
border-radius: 0.5rem;
|
|
|
|
}
|
|
|
|
</style>
|