This commit is contained in:
2025-11-21 11:51:31 +08:00
parent 7ea114d876
commit 4b9decaa2a
37 changed files with 6401 additions and 30 deletions

View File

@@ -1,9 +1,24 @@
---
import Layout from "@/layouts/Layout.astro";
import { getCollection, getEntry } from 'astro:content';
import PostLayout from '@/layouts/PostLayout.astro';
import { getReadingTime } from '@/utils/reading-time';
const { slug } = Astro.params;
if (!slug) {
return Astro.redirect('/404');
}
const post = await getEntry('posts', slug);
if (!post || post.data.draft) {
return Astro.redirect('/404');
}
const { Content } = await post.render();
const readingTime = getReadingTime(post.body);
---
<Layout>
<h1>Post Slug: {slug}</h1>
</Layout>
<PostLayout post={post} readingTime={readingTime}>
<Content />
</PostLayout>