diff --git a/apps/chat/src/layouts/navigation/links/navigation-item.tsx b/apps/chat/src/layouts/navigation/links/navigation-item.tsx index 1eaf2862..e27b7d47 100644 --- a/apps/chat/src/layouts/navigation/links/navigation-item.tsx +++ b/apps/chat/src/layouts/navigation/links/navigation-item.tsx @@ -3,6 +3,8 @@ import type { PropsWithChildren, ReactNode } from 'react'; import clsx from 'clsx'; import { Link, useLocation } from 'wouter'; +import { prefixWithBaseRoute } from '~/routes/use-sitemap'; + export type NavigationItemProps = PropsWithChildren & { path: string; icon: ReactNode; @@ -12,9 +14,9 @@ export type NavigationItemProps = PropsWithChildren & { export function NavigationItem({ path, icon, children, disabled }: NavigationItemProps) { const [location] = useLocation(); const isActive = ( - path !== '/' - ? location.startsWith(path) - : location === path + path === prefixWithBaseRoute('/') + ? location === path + : location.startsWith(path) ); return ( diff --git a/apps/chat/src/routes/use-sitemap.tsx b/apps/chat/src/routes/use-sitemap.tsx index 2663df5d..34d6ad52 100644 --- a/apps/chat/src/routes/use-sitemap.tsx +++ b/apps/chat/src/routes/use-sitemap.tsx @@ -36,6 +36,6 @@ export function useSitemap() { return sitemap; }; -function prefixWithBaseRoute(path: string) { - return concatUrls(import.meta.env.BASE_URL ?? '/', path); +export function prefixWithBaseRoute(path?: string) { + return concatUrls(import.meta.env.BASE_URL ?? '/', path ?? ''); }