25 lines
536 B
Plaintext
25 lines
536 B
Plaintext
---
|
|
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);
|
|
---
|
|
|
|
<PostLayout post={post} readingTime={readingTime}>
|
|
<Content />
|
|
</PostLayout>
|