jonbio/components/Header.tsx

54 lines
1.7 KiB
TypeScript
Raw Normal View History

2023-07-07 11:17:22 +08:00
import siteMetadata from '@/data/siteMetadata'
import headerNavLinks from '@/data/headerNavLinks'
import Logo from '@/data/logo.svg'
import Link from './Link'
import MobileNav from './MobileNav'
import ThemeSwitch from './ThemeSwitch'
2023-07-30 17:20:28 +08:00
import SearchButton from './SearchButton'
2023-07-07 11:17:22 +08:00
const Header = () => {
2024-07-30 14:34:19 -04:00
let headerClass = 'flex items-center w-full bg-white dark:bg-gray-950 justify-between py-10'
2024-07-30 08:37:51 -04:00
if (siteMetadata.stickyNav) {
2024-08-11 09:06:30 +02:00
headerClass += ' sticky top-0 z-50'
2024-07-25 01:52:13 -04:00
}
2023-07-07 11:17:22 +08:00
return (
2024-07-25 01:52:13 -04:00
<header className={headerClass}>
2024-07-30 14:34:19 -04:00
<Link href="/" aria-label={siteMetadata.headerTitle}>
<div className="flex items-center justify-between">
<div className="mr-3">
<Logo />
2023-07-07 11:17:22 +08:00
</div>
2024-07-30 14:34:19 -04:00
{typeof siteMetadata.headerTitle === 'string' ? (
<div className="hidden h-6 text-2xl font-semibold sm:block">
{siteMetadata.headerTitle}
</div>
) : (
siteMetadata.headerTitle
)}
</div>
</Link>
<div className="flex items-center space-x-4 leading-5 sm:space-x-6">
2025-01-28 14:32:15 -06:00
<div className="no-scrollbar hidden max-w-40 items-center space-x-4 overflow-x-scroll sm:flex sm:space-x-3 md:max-w-72 lg:max-w-96">
2024-07-30 14:34:19 -04:00
{headerNavLinks
.filter((link) => link.href !== '/')
.map((link) => (
<Link
key={link.title}
href={link.href}
className="block font-medium text-gray-900 hover:text-primary-500 dark:text-gray-100 dark:hover:text-primary-400"
>
{link.title}
</Link>
))}
</div>
2023-07-30 17:20:28 +08:00
<SearchButton />
2023-07-07 11:17:22 +08:00
<ThemeSwitch />
<MobileNav />
</div>
</header>
)
}
export default Header