This repository has been archived on 2024-07-16. You can view files and clone it, but cannot push or open issues or pull requests.
www.local-ip.sh/app/root.tsx

62 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-12-11 14:19:17 +00:00
import { cssBundleHref } from "@remix-run/css-bundle";
2023-12-13 20:48:50 +00:00
import { json, type SerializeFrom, type LinksFunction } from "@remix-run/node";
2023-12-11 14:19:17 +00:00
import {
2023-12-13 20:48:50 +00:00
Links,
LiveReload,
Meta,
Outlet,
Scripts,
ScrollRestoration,
useLoaderData,
2023-12-11 14:19:17 +00:00
} from "@remix-run/react";
2023-12-13 20:48:50 +00:00
import useFathom from "./hooks/use-fathom";
2023-12-11 14:19:17 +00:00
export const links: LinksFunction = () => [
2023-12-13 20:48:50 +00:00
...(cssBundleHref ? [{ rel: "stylesheet", href: cssBundleHref }] : []),
2023-12-11 14:19:17 +00:00
];
2023-12-13 20:48:50 +00:00
export const loader = () =>
json({
siteConfig: {
fathom: {
siteId: process.env.FATHOM_SITE_ID!,
domain: process.env.FATHOM_CUSTOM_DOMAIN!,
},
},
});
declare global {
interface Window {
siteConfig: SerializeFrom<typeof loader>["siteConfig"];
}
}
2023-12-11 14:19:17 +00:00
export default function App() {
2023-12-13 20:48:50 +00:00
const { siteConfig } = useLoaderData<typeof loader>();
useFathom();
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Links />
</head>
<body>
<Outlet />
<script
suppressHydrationWarning
dangerouslySetInnerHTML={{
__html: `window.siteConfig=${JSON.stringify(siteConfig)};`,
}}
/>
<ScrollRestoration />
<Scripts />
<LiveReload />
</body>
</html>
);
2023-12-11 14:19:17 +00:00
}