Created
November 24, 2021 12:18
-
-
Save codegino/130a151c71385cea4f043084c3aa7aee to your computer and use it in GitHub Desktop.
Remix Document Boilerplate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Links,LiveReload,Meta,Outlet,Scripts,ScrollRestoration} from "remix"; | |
export default function App() { | |
return ( | |
<Document> | |
<Layout> | |
<Outlet /> | |
</Layout> | |
</Document> | |
); | |
} | |
// Here is the blueprint of our document | |
// It looks like our typical HTML but with a few extra tags | |
// I will discuss in another blog post those Components coming from the remix package | |
function Document({ | |
children, | |
title, | |
}: { | |
children: React.ReactNode; | |
title?: string; | |
}) { | |
return ( | |
<html lang="en"> | |
<head> | |
<meta charSet="utf-8" /> | |
<meta name="viewport" content="width=device-width,initial-scale=1" /> | |
{title ? <title>{title}</title> : null} | |
<Meta /> | |
<Links /> | |
</head> | |
<body> | |
{children} | |
<ScrollRestoration /> | |
<Scripts /> | |
{process.env.NODE_ENV === "development" && <LiveReload />} | |
</body> | |
</html> | |
); | |
} | |
// Layout is a wrapper component that provides a consistent layout for all pages. | |
function Layout({ children }: React.PropsWithChildren<{}>) { | |
return <main>{children}</main>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment