Initial commit
This commit is contained in:
41
renderer/_default.page.client.tsx
Normal file
41
renderer/_default.page.client.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
import { StrictMode } from "react";
|
||||
import { createRoot, hydrateRoot } from "react-dom/client";
|
||||
import { ChakraProvider } from "@chakra-ui/react";
|
||||
import "../index.css";
|
||||
import "@fontsource/plus-jakarta-sans";
|
||||
import theme from "../theme";
|
||||
import * as Sentry from "@sentry/react";
|
||||
import { Integrations } from "@sentry/tracing";
|
||||
import Fallback from "../components/Fallback";
|
||||
import Navigation from "../components/Navigation";
|
||||
|
||||
Sentry.init({
|
||||
dsn: import.meta.env.VITE_DSN,
|
||||
integrations: [new Integrations.BrowserTracing()],
|
||||
tracesSampleRate: import.meta.env.VITE_SAMPLE_RATE
|
||||
? parseFloat(import.meta.env.VITE_SAMPLE_RATE)
|
||||
: 0.1,
|
||||
});
|
||||
|
||||
export async function render(pageContext: PageContext) {
|
||||
const { Page, pageProps } = pageContext;
|
||||
const root = document.getElementById("root") as HTMLElement;
|
||||
const reactRoot = (
|
||||
<StrictMode>
|
||||
<ChakraProvider theme={theme}>
|
||||
<div className="App">
|
||||
<Fallback>
|
||||
<Navigation {...pageContext.current_user} />
|
||||
<Page {...pageProps} />
|
||||
</Fallback>
|
||||
</div>
|
||||
</ChakraProvider>
|
||||
</StrictMode>
|
||||
);
|
||||
|
||||
if (root.innerHTML === "") {
|
||||
createRoot(root).render(reactRoot);
|
||||
} else {
|
||||
hydrateRoot(root, reactRoot);
|
||||
}
|
||||
}
|
||||
61
renderer/_default.page.server.tsx
Normal file
61
renderer/_default.page.server.tsx
Normal file
@@ -0,0 +1,61 @@
|
||||
import ReactDOMServer from "react-dom/server";
|
||||
import { StrictMode } from "react";
|
||||
import { dangerouslySkipEscape, escapeInject } from "vite-plugin-ssr";
|
||||
import theme from "../theme";
|
||||
import { ChakraProvider } from "@chakra-ui/react";
|
||||
import Fallback from "../components/Fallback";
|
||||
import Navigation from "../components/Navigation";
|
||||
import Login from "../components/Login";
|
||||
import Forbidden from "../components/Forbidden";
|
||||
|
||||
export const passToClient = ["current_user", "pageProps"];
|
||||
|
||||
export async function render(
|
||||
pageContext: PageContext & { pageProps: { [k: string]: any } }
|
||||
) {
|
||||
const { exports, Page, pageProps, status } = pageContext;
|
||||
|
||||
const reactHTML = Page
|
||||
? ReactDOMServer.renderToString(
|
||||
<StrictMode>
|
||||
<ChakraProvider theme={theme}>
|
||||
<div className="App">
|
||||
<Fallback>
|
||||
<Navigation {...pageContext.current_user} />
|
||||
{status === 200 ? (
|
||||
Page ? (
|
||||
<Page {...pageProps} />
|
||||
) : (
|
||||
""
|
||||
)
|
||||
) : (
|
||||
{ 401: <Login />, 403: <Forbidden /> }[status]
|
||||
)}
|
||||
</Fallback>
|
||||
</div>
|
||||
</ChakraProvider>
|
||||
</StrictMode>
|
||||
)
|
||||
: "";
|
||||
|
||||
return escapeInject`<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="theme-color" content="#00a8f8" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<link rel="apple-touch-icon" type="image/png" href="/files/logo192.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="${
|
||||
(exports.description as string) ?? "Car Crushers Website"
|
||||
}" />
|
||||
<meta property="og:description" content="${
|
||||
(exports.description as string | null) ?? "Car Crushers Website"
|
||||
}" />
|
||||
<title>${(exports.title as string | null) ?? "Car Crushers"}</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root">${dangerouslySkipEscape(reactHTML)}</div>
|
||||
</body>
|
||||
</html>`;
|
||||
}
|
||||
33
renderer/_error.page.tsx
Normal file
33
renderer/_error.page.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Container, Heading, Link, Text } from "@chakra-ui/react";
|
||||
import { PageContextBuiltIn } from "vite-plugin-ssr";
|
||||
|
||||
export function Page(pageProps: PageContextBuiltIn) {
|
||||
if (pageProps.is404)
|
||||
return (
|
||||
<Container maxW="container.lg" pt="8vh" textAlign="left">
|
||||
<Heading size="4xl">404</Heading>
|
||||
<br />
|
||||
<Text fontSize="xl">There is nothing to find here.</Text>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<Link color="#646cff" onClick={() => history.go(-1)}>
|
||||
Go back
|
||||
</Link>
|
||||
</Container>
|
||||
);
|
||||
|
||||
return (
|
||||
<Container maxW="container.lg" pt="8vh" textAlign="left">
|
||||
<Heading size="4xl">500</Heading>
|
||||
<br />
|
||||
<Text fontSize="xl">S̶̡͈̠̗̠͖͙̭o̶̶͕͚̥͍̪̤m̸̨͏͈͔̖͚̖̰̱͞e҉̵͖͚͇̀t̕͟͠͏͎̺̯̲̱̣̤̠̟͙̠̙̫̬ḩ̸̭͓̬͎̙̀į̞̮͉͖̰̥̹͚̫̙̪̗̜̳̕ͅn҉͔̯̪̗̝̝͖̲͇͍͎̲̲̤̖̫͈̪͡g̴̰̻̙̝͉̭͇̖̰̝̙͕̼͙͘͜ ̵̶̫̥̳̲̘̻̗͈͕̭̲͇̘̜̺̟̥̖̥b̴̙̭̹͕̞͠r̞͎̠̩͈̖̰̞̯̯͢͢͠ͅo̝̯̗̹̳͍̰͉͕̘̰̠̺̥̰͔̕ͅk̵̸̻̠͕̺̦̦͖̲̺̦̞̝̞͞͡e̶͏̤̼̼͔̘̰̰̭͈̀͞͡</Text>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<Link color="#646cff" onClick={() => location.reload()}>
|
||||
Reload
|
||||
</Link>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user