feat: rebuild app using vike

This commit is contained in:
2024-02-22 12:15:04 +00:00
parent 87ef4ca1e3
commit 9777ae1676
104 changed files with 2214 additions and 2976 deletions
+17
View File
@@ -0,0 +1,17 @@
import { useData } from "~/renderer/hooks";
import { Data } from "./+data";
import Link from "~/renderer/link";
const ViewPostPage = () => {
const { post } = useData<Data>();
return (
<div>
<Link href="/">Go Back</Link>
<h1>{post.title}</h1>
<p>{post.body}</p>
</div>
);
};
export default ViewPostPage;
+12
View File
@@ -0,0 +1,12 @@
import { PageContext } from "vike/types";
export const data = async (ctx: PageContext) => {
const id = ctx.routeParams?.id;
const post = await fetch(
"https://jsonplaceholder.typicode.com/posts/" + id
).then((response) => response.json());
return { post, title: post?.title };
};
export type Data = Awaited<ReturnType<typeof data>>;