feat: add image module

This commit is contained in:
2022-08-10 17:22:08 -04:00
parent e56325677c
commit f4c481b81d
10 changed files with 68 additions and 48 deletions

View File

@@ -1,10 +1,6 @@
<script setup lang="ts">
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc.js";
import type { BlogParsedContent } from "@/shared/types";
import { calcReadingTime } from "@/shared/readingTime";
dayjs.extend(utc);
import { calcReadingTime, getPrettyDate } from "@/shared/metadata";
const docs = await queryContent<BlogParsedContent>("/blog")
.sort({ date: 1 })
@@ -12,9 +8,7 @@ const docs = await queryContent<BlogParsedContent>("/blog")
.find();
const latest = docs.at(-1) as BlogParsedContent;
const latestDate = dayjs(latest.date).utc();
const prettyDate = latestDate.format("DD MMM YYYY");
const prettyDate = getPrettyDate(latest);
</script>
<template>

View File

@@ -1,10 +1,6 @@
<script setup lang="ts">
import type { StoryParsedContent, BlogParsedContent } from "@/shared/types";
import { calcReadingTime } from "@/shared/readingTime";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc.js";
dayjs.extend(utc);
import { calcReadingTime, getPrettyDate } from "@/shared/metadata";
const { post, type, highlighttags } = defineProps<{
post: StoryParsedContent | BlogParsedContent;
@@ -12,11 +8,6 @@ const { post, type, highlighttags } = defineProps<{
highlighttags?: string[];
}>();
const getPrettyDate = (story: StoryParsedContent) => {
const date = dayjs(story.date).utc();
return date.format("DD MMM YYYY");
};
const readingTime = calcReadingTime(post);
const descText =
type === "stories"

View File

@@ -1,10 +1,6 @@
<script setup lang="ts">
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc.js";
import { type StoryParsedContent } from "@/shared/types";
import { calcReadingTime } from "@/shared/readingTime";
dayjs.extend(utc);
import { calcReadingTime, getPrettyDate } from "@/shared/metadata";
const docs = await queryContent<StoryParsedContent>("/stories")
.sort({ date: 1 })
@@ -13,8 +9,7 @@ const docs = await queryContent<StoryParsedContent>("/stories")
const latest = docs.at(-1) as StoryParsedContent;
const latestDate = dayjs(latest.date).utc();
const prettyDate = latestDate.format("DD MMM YYYY");
const prettyDate = getPrettyDate(latest);
</script>
<template>

View File

@@ -0,0 +1,10 @@
<script setup lang="ts">
const { src } = defineProps<{ src: string }>();
</script>
<template>
<figure>
<img :src="`/images/posts/${src}`" />
<figcaption class="text-center"><Markdown /></figcaption>
</figure>
</template>