'use client'; import { clsx } from 'clsx/lite'; import { usePathname } from 'next/navigation'; import Link from 'next/link'; import AppGrid from '../components/AppGrid'; import ViewSwitcher, { SwitcherSelection } from '@/app/ViewSwitcher'; import { PATH_ROOT, isPathAdmin, isPathFeed, isPathGrid, isPathTopLevel, isPathProtected, isPathSignIn, } from '@/app/paths'; import AnimateItems from '../components/AnimateItems'; import { GRID_HOMEPAGE_ENABLED, HAS_DEFINED_SITE_DESCRIPTION, SITE_DESCRIPTION, } from './config'; import { useRef } from 'react'; import useStickyNav from './useStickyNav'; const NAV_HEIGHT_CLASS = HAS_DEFINED_SITE_DESCRIPTION ? 'min-h-[4rem] sm:min-h-[5rem]' : 'min-h-[4rem]'; export default function Nav({ siteDomainOrTitle, }: { siteDomainOrTitle: string; }) { const ref = useRef(null); const pathname = usePathname(); const showNav = !isPathSignIn(pathname); const isHome = isPathTopLevel(pathname); const { isNavSticky, shouldHideStickyNav, shouldAnimateStickyNav, } = useStickyNav(ref, isHome); const renderLink = ( text: string, linkOrAction: string | (() => void), ) => typeof linkOrAction === 'string' ? {text} : ; const switcherSelectionForPath = (): SwitcherSelection | undefined => { if (pathname === PATH_ROOT) { return GRID_HOMEPAGE_ENABLED ? 'grid' : 'feed'; } else if (isPathGrid(pathname)) { return 'grid'; } else if (isPathFeed(pathname)) { return 'feed'; } else if (isPathProtected(pathname)) { return 'admin'; } }; return (
{renderLink(siteDomainOrTitle, PATH_ROOT)}
{HAS_DEFINED_SITE_DESCRIPTION &&
{SITE_DESCRIPTION}
}
] : []} /> } sideHiddenOnMobile /> ); };