import { Links, Meta, Outlet, Scripts, ScrollRestoration } from "@remix-run/react"; import type { LinksFunction, LoaderFunctionArgs, MetaFunction } from "@remix-run/node"; import { type UseDataFunctionReturn, typedjson, useTypedLoaderData } from "remix-typedjson"; import tailwindStylesheetUrl from "~/tailwind.css"; import { appEnvTitleTag } from "./utils"; import { commitSession, getSession, type ToastMessage } from "./models/message.server"; import { env } from "./env.server"; export const links: LinksFunction = () => [ { rel: "preconnect", href: "https://fonts.googleapis.com" }, { rel: "preconnect", href: "https://fonts.gstatic.com", crossOrigin: "anonymous", }, { rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap", }, { rel: "stylesheet", href: tailwindStylesheetUrl }, ]; export const loader = async ({ request }: LoaderFunctionArgs) => { const session = await getSession(request.headers.get("cookie")); const toastMessage = session.get("toastMessage") as ToastMessage; const posthogProjectKey = env.POSTHOG_PROJECT_KEY; return typedjson( { user: await getUser(request), toastMessage, posthogProjectKey, appEnv: env.APP_ENV, appOrigin: env.APP_ORIGIN, }, { headers: { "Set-Cookie": await commitSession(session) } } ); }; export const meta: MetaFunction = ({ data }) => { const typedData = data as UseDataFunctionReturn; return [ { title: `Echo${appEnvTitleTag(typedData.appEnv)}` }, { name: "viewport", content: "width=1024, initial-scale=1", }, { name: "robots", content: typeof window === "undefined" || window.location.hostname !== "echo.mysigma.ai" ? "noindex, nofollow" : "index, follow", }, ]; }; export function Layout({ children }: { children: React.ReactNode }) { return ( {children} ); } export default function App() { return ; }