Draft implementation of comments
This commit is contained in:
parent
62f3e0d72f
commit
fafce18907
2 changed files with 38 additions and 2 deletions
|
@ -1,18 +1,29 @@
|
|||
import { useParams } from "@solidjs/router";
|
||||
import { JSXElement, Show, Suspense, createResource } from "solid-js";
|
||||
import { For, JSXElement, Show, Suspense, createResource } from "solid-js";
|
||||
|
||||
import { loadSpinner } from "../Util/Icons";
|
||||
import { getPost } from "../Util/api";
|
||||
import { getComments, getPost } from "../Util/api";
|
||||
import { PostSegment } from "./Posts";
|
||||
|
||||
export function SinglePost(): JSXElement {
|
||||
const params = useParams();
|
||||
const [post] = createResource(params.postid, getPost);
|
||||
const [comments] = createResource(params.postid, () =>
|
||||
getComments(params.postid, 0, 10)
|
||||
);
|
||||
|
||||
return (
|
||||
<Suspense fallback={loadSpinner()}>
|
||||
<Show when={post()}>
|
||||
<PostSegment post={post()!} />
|
||||
<For each={comments()!}>
|
||||
{(comment) => (
|
||||
// TODO: This should be a separate component
|
||||
<div class="comment">
|
||||
<p>{comment.content}</p>
|
||||
</div>
|
||||
)}
|
||||
</For>
|
||||
</Show>
|
||||
</Suspense>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue