create remix project
This commit is contained in:
4
docs/app/entry.client.tsx
Normal file
4
docs/app/entry.client.tsx
Normal file
@@ -0,0 +1,4 @@
|
||||
import { hydrate } from "react-dom";
|
||||
import { RemixBrowser } from "remix";
|
||||
|
||||
hydrate(<RemixBrowser />, document);
|
||||
21
docs/app/entry.server.tsx
Normal file
21
docs/app/entry.server.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import { renderToString } from "react-dom/server";
|
||||
import { RemixServer } from "remix";
|
||||
import type { EntryContext } from "remix";
|
||||
|
||||
export default function handleRequest(
|
||||
request: Request,
|
||||
responseStatusCode: number,
|
||||
responseHeaders: Headers,
|
||||
remixContext: EntryContext
|
||||
) {
|
||||
const markup = renderToString(
|
||||
<RemixServer context={remixContext} url={request.url} />
|
||||
);
|
||||
|
||||
responseHeaders.set("Content-Type", "text/html");
|
||||
|
||||
return new Response("<!DOCTYPE html>" + markup, {
|
||||
status: responseStatusCode,
|
||||
headers: responseHeaders
|
||||
});
|
||||
}
|
||||
32
docs/app/root.tsx
Normal file
32
docs/app/root.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import {
|
||||
Links,
|
||||
LiveReload,
|
||||
Meta,
|
||||
Outlet,
|
||||
Scripts,
|
||||
ScrollRestoration
|
||||
} from "remix";
|
||||
import type { MetaFunction } from "remix";
|
||||
|
||||
export const meta: MetaFunction = () => {
|
||||
return { title: "New Remix App" };
|
||||
};
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charSet="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<Meta />
|
||||
<Links />
|
||||
</head>
|
||||
<body>
|
||||
<Outlet />
|
||||
<ScrollRestoration />
|
||||
<Scripts />
|
||||
{process.env.NODE_ENV === "development" && <LiveReload />}
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
16
docs/app/routes/index.tsx
Normal file
16
docs/app/routes/index.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import { readFile } from "fs/promises"
|
||||
import { json, LoaderFunction, useLoaderData } from "remix"
|
||||
|
||||
export const loader: LoaderFunction = async () => {
|
||||
const docs = await readFile("app/docs.json", "utf8")
|
||||
return json(JSON.parse(docs))
|
||||
}
|
||||
|
||||
export default function Index() {
|
||||
const data = useLoaderData()
|
||||
return (
|
||||
<main>
|
||||
<pre>{JSON.stringify(data, undefined, 2)}</pre>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user