2023-10-27 16:04:58 +02:00
|
|
|
import { useParams } from "@solidjs/router";
|
2023-11-13 12:00:46 +01:00
|
|
|
import { JSXElement, Show, Suspense, createResource } from "solid-js";
|
2023-11-15 07:29:59 +01:00
|
|
|
|
2023-11-13 12:10:40 +01:00
|
|
|
import { loadSpinner } from "./Icons";
|
2023-11-15 07:29:59 +01:00
|
|
|
import { PostSegment } from "./Posts";
|
|
|
|
import { getPost } from "./api";
|
2023-10-27 16:04:58 +02:00
|
|
|
|
2023-11-13 12:00:46 +01:00
|
|
|
export function SinglePost(): JSXElement {
|
2023-10-27 16:04:58 +02:00
|
|
|
const params = useParams();
|
|
|
|
const [post] = createResource(params.postid, getPost);
|
|
|
|
|
|
|
|
return (
|
2023-11-13 12:10:40 +01:00
|
|
|
<Suspense fallback={loadSpinner()}>
|
2023-11-15 07:29:59 +01:00
|
|
|
<Show when={post()}>
|
|
|
|
<PostSegment post={post()!} />
|
|
|
|
</Show>
|
2023-10-27 16:04:58 +02:00
|
|
|
</Suspense>
|
|
|
|
);
|
|
|
|
}
|