feat: add project schema

This commit is contained in:
2024-02-22 20:59:20 +00:00
parent b232410d83
commit d579c1b7c5
27 changed files with 338 additions and 147 deletions
+4 -8
View File
@@ -3,19 +3,15 @@ import { useData } from "~/renderer/hooks";
import Link from "~/renderer/link";
const HomePage = () => {
const { posts } = useData<Data>();
if (!posts?.length) {
return <p>No posts.</p>;
}
const { projects } = useData<Data>();
return (
<div>
<h1>Posts</h1>
{posts.map((post: any) => (
<Link key={post.id} href={`/${post.id}`}>
{post.title}
{projects.map((project: any) => (
<Link key={project.id} href={`/${project.slug}`}>
{project.title}
</Link>
))}
</div>
+8 -5
View File
@@ -1,9 +1,12 @@
export const data = async () => {
const posts = await fetch(
"https://jsonplaceholder.typicode.com/posts?_limit=20"
).then((response) => response.json());
import { PageContext } from "vike/types";
import trpcServer from "~/server/api/trpc/trpc";
return { posts };
export const data = async (ctx: PageContext) => {
const trpc = await trpcServer(ctx);
const projects = await trpc.project.getAll();
return { projects };
};
export type Data = Awaited<ReturnType<typeof data>>;