import { Toaster } from "@pram/ui/components/sonner"; import type { QueryClient } from "@tanstack/react-query"; import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; import { HeadContent, Outlet, createRootRouteWithContext, useRouterState } from "@tanstack/react-router"; import { TanStackRouterDevtools } from "@tanstack/react-router-devtools"; import { Sidebar } from "@/components/sidebar"; import { ThemeProvider } from "@/components/theme-provider"; import { useSidebar } from "@/hooks/use-sidebar"; import { GlobalGenerationProgress } from "@/components/generate/GlobalGenerationProgress"; import { ErrorFallback } from "@/components/ErrorFallback"; import type { RouteShell } from "@/lib/route-shell"; import { buildSocialMeta, DEFAULT_SITE_DESCRIPTION, DEFAULT_SITE_TITLE, SITE_URL, } from "@/lib/site-seo"; import type { trpc } from "@/utils/trpc"; function SkipLink() { return ( Lewati ke konten utama ); } import "../index.css"; export interface RouterAppContext { trpc: typeof trpc; queryClient: QueryClient; } function resolveShell(matches: { staticData?: unknown }[]): RouteShell { for (let i = matches.length - 1; i >= 0; i--) { const shell = (matches[i]?.staticData as { shell?: RouteShell } | undefined)?.shell; if (shell) return shell; } return "app"; } export const Route = createRootRouteWithContext()({ component: RootComponent, errorComponent: ({ error, reset }) => , head: () => { return { meta: [ { title: DEFAULT_SITE_TITLE }, { name: "description", content: DEFAULT_SITE_DESCRIPTION }, ...buildSocialMeta(), { name: "robots", content: "index, follow" }, ], links: [ { rel: "icon", href: "/pram_icon.png" }, { rel: "canonical", href: `${SITE_URL}/` }, { rel: "preconnect", href: "https://fonts.googleapis.com" }, { rel: "preconnect", href: "https://fonts.gstatic.com", crossOrigin: "anonymous" as const }, { rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800&family=Inter:wght@400;500;600&family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0&display=swap" }, ], scripts: [ { type: "application/ld+json", children: JSON.stringify({ "@context": "https://schema.org", "@type": "WebSite", name: "Pram", url: SITE_URL, description: DEFAULT_SITE_DESCRIPTION, potentialAction: { "@type": "SearchAction", target: `${SITE_URL}/bank?search={search_term_string}`, "query-input": "required name=search_term_string", }, }), }, ], }; }, }); function RootComponent() { const { collapsed } = useSidebar(); const shell = useRouterState({ select: (s) => resolveShell(s.matches) }); return ( <> {shell === "fullscreen" ? (
) : shell === "public" ? (
) : (
)} {shell !== "public" && }
{import.meta.env.DEV && ( <> )} ); }