diff --git a/src/site/Nav.tsx b/src/site/Nav.tsx index aca0e5b5..18691025 100644 --- a/src/site/Nav.tsx +++ b/src/site/Nav.tsx @@ -1,75 +1,12 @@ -'use client'; - -import { clsx } from 'clsx/lite'; -import { usePathname } from 'next/navigation'; -import Link from 'next/link'; -import SiteGrid from '../components/SiteGrid'; -import { SITE_DOMAIN_OR_TITLE } from '@/site/config'; -import ViewSwitcher, { SwitcherSelection } from '@/site/ViewSwitcher'; -import { - PATH_ROOT, - isPathAdmin, - isPathGrid, - isPathProtected, - isPathSets, - isPathSignIn, -} from '@/site/paths'; -import AnimateItems from '../components/AnimateItems'; - -export default function Nav() { - const pathname = usePathname(); - - const showNav = !isPathSignIn(pathname); - - const shouldAnimate = !isPathAdmin(pathname); - - const renderLink = ( - text: string, - linkOrAction: string | (() => void), - ) => - typeof linkOrAction === 'string' - ? {text} - : ; - - const switcherSelectionForPath = (): SwitcherSelection | undefined => { - if (pathname === PATH_ROOT) { - return 'full-frame'; - } else if (isPathGrid(pathname)) { - return 'grid'; - } else if (isPathSets(pathname)) { - return 'sets'; - } else if (isPathProtected(pathname)) { - return 'admin'; - } - }; +import { authCached } from '@/cache'; +import NavClient from './NavClient'; +import { Suspense } from 'react'; +export default async function Nav() { + const session = await authCached(); return ( - -
- -
-
- {renderLink(SITE_DOMAIN_OR_TITLE, PATH_ROOT)} -
- ] - : []} - /> - } - /> + }> + + ); -}; +} diff --git a/src/site/NavClient.tsx b/src/site/NavClient.tsx new file mode 100644 index 00000000..54493173 --- /dev/null +++ b/src/site/NavClient.tsx @@ -0,0 +1,79 @@ +'use client'; + +import { clsx } from 'clsx/lite'; +import { usePathname } from 'next/navigation'; +import Link from 'next/link'; +import SiteGrid from '../components/SiteGrid'; +import { SITE_DOMAIN_OR_TITLE } from '@/site/config'; +import ViewSwitcher, { SwitcherSelection } from '@/site/ViewSwitcher'; +import { + PATH_ROOT, + isPathAdmin, + isPathGrid, + isPathProtected, + isPathSets, + isPathSignIn, +} from '@/site/paths'; +import AnimateItems from '../components/AnimateItems'; + +export default function NavClient({ + showAdmin, +}: { + showAdmin?: boolean, +}) { + const pathname = usePathname(); + + const showNav = !isPathSignIn(pathname); + + const shouldAnimate = !isPathAdmin(pathname); + + const renderLink = ( + text: string, + linkOrAction: string | (() => void), + ) => + typeof linkOrAction === 'string' + ? {text} + : ; + + const switcherSelectionForPath = (): SwitcherSelection | undefined => { + if (pathname === PATH_ROOT) { + return 'full-frame'; + } else if (isPathGrid(pathname)) { + return 'grid'; + } else if (isPathSets(pathname)) { + return 'sets'; + } else if (isPathProtected(pathname)) { + return 'admin'; + } + }; + + return ( + +
+ +
+
+ {renderLink(SITE_DOMAIN_OR_TITLE, PATH_ROOT)} +
+ ] + : []} + /> + } + /> + ); +};