import Link from 'next/link' import { useRouter } from 'next/router' import GitHub from './GitHub' import { LineChart } from './LineChart' import ThemeSwitcher from './ThemeSwitcher' type HeaderProps = { name: string darkMode: boolean setDarkMode: (state: boolean) => void searchIndex: SearchIndex } import * as React from 'react' import Search from './Search' import { SearchIndex, SearchItem } from '../utils/search' import Fuse 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, darkMode, setDarkMode, searchIndex, }: HeaderProps) { const router = useRouter() const fuse = React.useMemo(() => { const options: Fuse.IFuseOptions = {} return new Fuse( searchIndex.list, options, Fuse.parseIndex(searchIndex.index) ) }, [searchIndex]) return (

{name}

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