feat: main

This commit is contained in:
Nikolaj Frey 2023-06-27 10:28:54 +10:00
parent 68c52422cf
commit 0816b3d980
2 changed files with 21 additions and 20 deletions

View File

@ -1,8 +1,8 @@
import { renderToString } from "react-dom/server"; import { renderToString } from 'react-dom/server'
import { RemixServer } from "remix"; import { RemixServer } from '@remix-run/react'
import type { EntryContext } from "remix"; import type { EntryContext } from '@remix-run/react/dist/entry'
export default function handleRequest( export default function handleRequest (
request: Request, request: Request,
responseStatusCode: number, responseStatusCode: number,
responseHeaders: Headers, responseHeaders: Headers,
@ -10,12 +10,12 @@ export default function handleRequest(
) { ) {
let markup = renderToString( let markup = renderToString(
<RemixServer context={remixContext} url={request.url} /> <RemixServer context={remixContext} url={request.url} />
); )
responseHeaders.set("Content-Type", "text/html"); responseHeaders.set('Content-Type', 'text/html')
return new Response("<!DOCTYPE html>" + markup, { return new Response('<!DOCTYPE html>' + markup, {
status: responseStatusCode, status: responseStatusCode,
headers: responseHeaders headers: responseHeaders
}); })
} }

View File

@ -1,30 +1,31 @@
import { ChakraProvider } from "@chakra-ui/react" import { ChakraProvider } from '@chakra-ui/react'
import type { MetaFunction } from "@vercel/remix" // import type { MetaFunction } from "@vercel/remix"
import type { MetaFunction } from '@remix-run/node'
import { import {
Links, Links,
LiveReload, LiveReload,
Meta, Meta,
Outlet, Outlet,
Scripts, Scripts,
ScrollRestoration, ScrollRestoration
} from "@remix-run/react" } from '@remix-run/react'
import { Analytics } from "@vercel/analytics/react" import { Analytics } from '@vercel/analytics/react'
export const meta: MetaFunction = () => ({ export const meta: MetaFunction = () => ({
charset: "utf-8", charset: 'utf-8',
title: "New Remix App", title: 'New Remix App',
viewport: "width=device-width,initial-scale=1", viewport: 'width=device-width,initial-scale=1'
}) })
function Document({ function Document ({
children, children,
title = "App title", title = 'App title'
}: { }: {
children: React.ReactNode children: React.ReactNode
title?: string title?: string
}) { }) {
return ( return (
<html lang="en"> <html lang='en'>
<head> <head>
<Meta /> <Meta />
<title>{title}</title> <title>{title}</title>
@ -41,7 +42,7 @@ function Document({
) )
} }
export default function App() { export default function App () {
return ( return (
<Document> <Document>
<ChakraProvider> <ChakraProvider>