import { createSignal } from "solid-js"; import { getPosts } from "./api"; import { Post } from "./api"; import { useNavigate } from "@solidjs/router"; export function Posts() { const [posts, setPosts] = createSignal([] as Post[]); const [loading, setLoading] = createSignal(true); getPosts().then((posts) => { setPosts(posts as any); setLoading(false); }); return (
{loading() ? ( ) : ( <> )} {posts().map((post) => { if (post.content == "") return; // Filtering out empty posts, remove this later return ; })}
); } // This is the card container for a post export function PostSegment({ post }: { post: Post }) { const nav = useNavigate(); return (
nav("/post/" + post?.id)} class="card bg-base-200 shadow-lg compact text-base-content w-full" >

{post?.content}

); }