FrostByte/client-solid/src/SinglePost.tsx

20 lines
514 B
TypeScript
Raw Normal View History

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
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 (
<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>
);
}