-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathroot.tsx
71 lines (63 loc) · 1.56 KB
/
root.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import type {
LinksFunction,
LoaderFunction,
MetaFunction,
} from "@remix-run/node";
import { json } from "@remix-run/node";
import {
Links,
LiveReload,
Meta,
Outlet,
Scripts,
ScrollRestoration,
useLoaderData,
} from "@remix-run/react";
import { useTranslation } from "react-i18next";
import { useChangeLanguage } from "remix-i18next";
import { i18nextServer } from "~/integrations/i18n";
import tailwindStylesheetUrl from "./styles/tailwind.css";
import { getBrowserEnv } from "./utils/env";
export const links: LinksFunction = () => [
{ rel: "stylesheet preload prefetch", href: tailwindStylesheetUrl, as: "style" },
];
export const meta: MetaFunction = () => [
{ title: "Remix Notes" },
{ name: "description", content: "Remix Notes App" },
];
export const loader: LoaderFunction = async ({ request }) => {
const locale = await i18nextServer.getLocale(request);
return json({
locale,
env: getBrowserEnv(),
});
};
export default function App() {
const { env, locale } = useLoaderData<typeof loader>();
const { i18n } = useTranslation();
useChangeLanguage(locale);
return (
<html lang={locale} dir={i18n.dir()} className="h-full">
<head>
<meta charSet="utf-8" />
<meta
name="viewport"
content="width=device-width,initial-scale=1.0,maximum-scale=1.0"
/>
<Meta />
<Links />
</head>
<body className="h-full">
<Outlet />
<ScrollRestoration />
<script
dangerouslySetInnerHTML={{
__html: `window.env = ${JSON.stringify(env)}`,
}}
/>
<Scripts />
<LiveReload />
</body>
</html>
);
}