2023-05-15 14:52:29 +00:00
|
|
|
---
|
2024-04-02 11:22:20 +00:00
|
|
|
import BaseLayout from "@/layouts/BaseLayout.astro";
|
2023-06-17 10:21:29 +00:00
|
|
|
import Content from "@/components/Content.astro";
|
|
|
|
import type { Post } from "@/types";
|
|
|
|
import { getPost, getPosts } from "@/utils/payload";
|
2023-05-15 15:11:32 +00:00
|
|
|
|
2023-05-15 14:52:29 +00:00
|
|
|
export async function getStaticPaths() {
|
2023-05-15 15:38:17 +00:00
|
|
|
const posts = await getPosts();
|
|
|
|
const paths = posts.map((post: Post) => ({
|
2023-05-15 14:52:29 +00:00
|
|
|
params: { id: post.id },
|
|
|
|
}));
|
|
|
|
return paths;
|
|
|
|
}
|
2023-05-15 15:38:17 +00:00
|
|
|
|
2023-05-15 14:52:29 +00:00
|
|
|
const { id } = Astro.params;
|
2023-05-15 15:38:17 +00:00
|
|
|
const post = id && (await getPost(id));
|
2023-05-15 14:52:29 +00:00
|
|
|
---
|
|
|
|
|
2023-05-15 15:38:17 +00:00
|
|
|
{
|
|
|
|
post ? (
|
2024-04-02 11:22:20 +00:00
|
|
|
<BaseLayout title={`Astroad | ${post.title!}`}>
|
2023-05-17 09:56:36 +00:00
|
|
|
<div class="space-y-3 my-3">
|
2023-05-15 15:38:17 +00:00
|
|
|
<a href="/">BACK</a>
|
2023-08-15 19:08:39 +00:00
|
|
|
<h1 class="font-bold text-5xl" transition:name=`title-${post.id}`>{post.title}</h1>
|
2023-05-17 07:18:08 +00:00
|
|
|
{post.content && <Content content={post.content} />}
|
2023-05-15 15:38:17 +00:00
|
|
|
</div>
|
2024-04-02 11:22:20 +00:00
|
|
|
</BaseLayout>
|
2023-05-15 15:38:17 +00:00
|
|
|
) : (
|
|
|
|
<div>404</div>
|
|
|
|
)
|
|
|
|
}
|