1
0
Fork 0
mirror of https://github.com/kou029w/quot.git synced 2025-01-19 00:18:09 +00:00
quot/app/src/pages/page.tsx

30 lines
656 B
TypeScript
Raw Normal View History

2022-08-23 09:01:47 +09:00
import { createResource } from "solid-js";
import Editor from "../components/editor";
type PageResponse = {
id: number;
title: string;
text: string;
created: string;
updated: string;
};
async function fetchPage(id: number): Promise<PageResponse> {
const res = await fetch(
new URL(`/pages?id=eq.${id}`, import.meta.env.QUOT_API_URL)
);
const [data] = await res.json();
return data as PageResponse;
}
export default (props: { id: number }) => {
const [page] = createResource(props.id, fetchPage);
return (
<main>
2022-08-24 09:50:35 +09:00
<Editor id={props.id} />
2022-08-23 09:01:47 +09:00
<pre>{() => JSON.stringify(page(), null, " ")}</pre>
</main>
);
};