1. Marketing Layout: speed up rendering by retrieving user session from cookies instead of using server side request 2. Use "redirecting" state when signing in to keep displaying a loading state while Next.js redirects to home page 3. Use "useCallback" to prevent double tracking when switching pages 4. Add links pre-fetching in marketing navigation 5. Add new pending state to MFA verification form 6. Pre-fetch sign-in/sign-up pages 7. Fix i18n when using regional languages 8. currency formatter should default to the region if it exists 9. Update packages
38 lines
944 B
TypeScript
38 lines
944 B
TypeScript
'use client';
|
|
|
|
import Link from 'next/link';
|
|
import { usePathname } from 'next/navigation';
|
|
|
|
import { NavigationMenuItem } from '@kit/ui/navigation-menu';
|
|
import { cn, isRouteActive } from '@kit/ui/utils';
|
|
|
|
const getClassName = (path: string, currentPathName: string) => {
|
|
const isActive = isRouteActive(path, currentPathName);
|
|
|
|
return cn(
|
|
`inline-flex w-max text-sm font-medium transition-colors duration-300`,
|
|
{
|
|
'dark:text-gray-300 dark:hover:text-white': !isActive,
|
|
'text-current dark:text-white': isActive,
|
|
},
|
|
);
|
|
};
|
|
|
|
export function SiteNavigationItem({
|
|
path,
|
|
children,
|
|
}: React.PropsWithChildren<{
|
|
path: string;
|
|
}>) {
|
|
const currentPathName = usePathname();
|
|
const className = getClassName(path, currentPathName);
|
|
|
|
return (
|
|
<NavigationMenuItem key={path}>
|
|
<Link className={className} href={path} as={path} prefetch={true}>
|
|
{children}
|
|
</Link>
|
|
</NavigationMenuItem>
|
|
);
|
|
}
|