'use client'; import { VscGithubInverted } from '@react-icons/all-files/vsc/VscGithubInverted'; import { VscMenu } from '@react-icons/all-files/vsc/VscMenu'; import { Button } from 'ariakit/button'; import dynamic from 'next/dynamic'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; import { Fragment, useMemo } from 'react'; import { useNav } from '~/contexts/nav'; const ThemeSwitcher = dynamic(async () => import('./ThemeSwitcher')); export default function Header() { const pathname = usePathname(); const { setOpened } = useNav(); const pathElements = useMemo( () => pathname .split('/') .slice(1) .map((path, idx, original) => ( {path} )), [pathname], ); const breadcrumbs = useMemo( () => pathElements.flatMap((el, idx, array) => { if (idx === 0) { return (
/
{el}
/
); } if (idx !== array.length - 1) { return (
{el}
/
); } return
{el}
; }), [pathElements], ); return (
{breadcrumbs}
); }