import Link from 'next/link' import { useRouter } from 'next/router' import GitHub from './GitHub' import ThemeSwitcher from './ThemeSwitcher' type HeaderProps = { name: string setDarkMode: (state: boolean) => void searchIndex: SearchIndex } import * as React from 'react' import Search from './Search' import { SearchIndex, SearchItem } from '../utils/search' import Fuse, { IFuseOptions } from 'fuse.js' interface NavLinkProps { href: string name: string } const NavLink: React.FunctionComponent = (props) => { const router = useRouter() const bg = router.asPath.startsWith(props.href) ? 'bg-rose-100 dark:bg-rose-900' : '' return ( {props.name} ) } export default function Header({ name, setDarkMode, searchIndex, }: HeaderProps) { const router = useRouter() const fuse = React.useMemo(() => { const options: IFuseOptions = {} return new Fuse( searchIndex.list, options, Fuse.parseIndex(searchIndex.index) ) }, [searchIndex]) return (

{name}

{router.asPath != '/' && (
)}
) }