From 59e0c6ae97c14ed233c709d9bf902141e0332876 Mon Sep 17 00:00:00 2001 From: Anthony Malkoun Date: Wed, 14 Aug 2024 11:53:10 +0300 Subject: [PATCH] Conditionally place umami script in route root --- frontend/src/routes/__root.tsx | 11 ++++++++++- frontend/src/routes/_landing.tsx | 9 +-------- frontend/src/routes/index.tsx | 11 +---------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/frontend/src/routes/__root.tsx b/frontend/src/routes/__root.tsx index c6e18fa8..4acb6cc7 100644 --- a/frontend/src/routes/__root.tsx +++ b/frontend/src/routes/__root.tsx @@ -1,8 +1,17 @@ import { createRootRouteWithContext, Outlet } from "@tanstack/react-router"; import { QueryClient } from "@tanstack/react-query"; import { AppLayout } from "@/components/Home/Main"; +import UmamiScript from "@/components/Landing/Umami"; -const rootComponent = process.env.NODE_ENV === "local" ? AppLayout : Outlet; +const rootComponent = + process.env.NODE_ENV === "local" + ? AppLayout + : () => ( + <> + + + + ); export const Route = createRootRouteWithContext<{ queryClient: QueryClient; }>()({ diff --git a/frontend/src/routes/_landing.tsx b/frontend/src/routes/_landing.tsx index ad254201..14484cc0 100644 --- a/frontend/src/routes/_landing.tsx +++ b/frontend/src/routes/_landing.tsx @@ -1,5 +1,4 @@ -import UmamiScript from "@/components/Landing/Umami"; -import { createFileRoute, Outlet, redirect } from "@tanstack/react-router"; +import { createFileRoute, redirect } from "@tanstack/react-router"; export const Route = createFileRoute("/_landing")({ beforeLoad: () => { @@ -7,10 +6,4 @@ export const Route = createFileRoute("/_landing")({ throw redirect({ to: "/" }); } }, - component: () => ( - <> - - - - ), }); diff --git a/frontend/src/routes/index.tsx b/frontend/src/routes/index.tsx index 544b72cb..cd757c55 100644 --- a/frontend/src/routes/index.tsx +++ b/frontend/src/routes/index.tsx @@ -1,16 +1,7 @@ import { createFileRoute } from "@tanstack/react-router"; import { Landing } from "@components/Landing/Landing"; import { ConnectionSelector } from "@/components/Connection/ConnectionSelector"; -import UmamiScript from "@/components/Landing/Umami"; export const Route = createFileRoute("/")({ - component: - process.env.NODE_ENV === "local" - ? ConnectionSelector - : () => ( - <> - - - - ), + component: process.env.NODE_ENV === "local" ? ConnectionSelector : Landing, });