2024-04-16 13:40:25 -07:00
|
|
|
"use client";
|
|
|
|
|
2024-04-17 15:04:32 -07:00
|
|
|
import GitHubStarButton from "@/components/github-star-button";
|
2024-04-15 15:00:47 -07:00
|
|
|
import config from "@/config";
|
2024-04-15 19:31:55 -07:00
|
|
|
import { minecrafter } from "@/font/fonts";
|
|
|
|
import { cn } from "@/lib/utils";
|
2024-04-15 19:53:23 -07:00
|
|
|
import Image from "next/image";
|
2024-04-15 15:00:47 -07:00
|
|
|
import Link from "next/link";
|
2024-04-16 13:40:25 -07:00
|
|
|
import { usePathname } from "next/navigation";
|
2024-04-17 16:04:15 -07:00
|
|
|
import { ReactElement } from "react";
|
2024-04-15 15:00:47 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The navbar for the site.
|
|
|
|
*
|
|
|
|
* @returns the navbar jsx
|
|
|
|
*/
|
2024-04-17 16:04:15 -07:00
|
|
|
const Navbar = (): ReactElement => {
|
|
|
|
const path: string = usePathname(); // Get the current path
|
|
|
|
return (
|
2024-04-18 13:44:25 -07:00
|
|
|
<nav className="fixed inset-x-0 flex h-16 px-5 sm:px-12 justify-center sm:justify-between items-center bg-navbar-background z-50">
|
2024-04-17 16:04:15 -07:00
|
|
|
{/* Left */}
|
|
|
|
<div className="flex gap-3 xs:gap-7 lg:gap-12 items-center transition-all transform-gpu">
|
|
|
|
{/* App Branding */}
|
|
|
|
<Link
|
|
|
|
className={cn(
|
|
|
|
"text-3xl text-minecraft-green-3 hover:opacity-85 transition-all transform-gpu",
|
|
|
|
minecrafter.className
|
|
|
|
)}
|
|
|
|
href="/"
|
|
|
|
>
|
|
|
|
{/* Small Screens */}
|
|
|
|
<Image
|
|
|
|
className="lg:hidden"
|
|
|
|
src="/media/logo.webp"
|
|
|
|
alt="Site Logo"
|
|
|
|
width={42}
|
|
|
|
height={42}
|
|
|
|
/>
|
2024-04-15 19:53:23 -07:00
|
|
|
|
2024-04-17 16:04:15 -07:00
|
|
|
{/* Large Screens */}
|
|
|
|
<span className="hidden lg:flex">{config.siteName}</span>
|
|
|
|
</Link>
|
2024-04-16 13:40:25 -07:00
|
|
|
|
2024-04-17 16:04:15 -07:00
|
|
|
{/* Links */}
|
|
|
|
<div className="flex gap-7">
|
|
|
|
{Object.entries(config.navbarLinks).map(
|
|
|
|
(link: [string, string], index: number) => {
|
|
|
|
const url: string = link[1]; // The href of the link
|
|
|
|
let active: boolean = path.startsWith(url); // Is this the active link?
|
|
|
|
return (
|
|
|
|
<Link
|
|
|
|
key={index}
|
|
|
|
className={cn(
|
|
|
|
"font-semibold uppercase hover:text-minecraft-green-4 transition-all transform-gpu",
|
|
|
|
active && "text-minecraft-green-4"
|
|
|
|
)}
|
|
|
|
href={url}
|
|
|
|
>
|
|
|
|
{link[0]}
|
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-04-15 19:31:55 -07:00
|
|
|
|
2024-04-17 16:04:15 -07:00
|
|
|
{/* Social Buttons - Right */}
|
|
|
|
<div className="hidden md:flex">
|
|
|
|
{/* Star on Github <3 */}
|
|
|
|
<GitHubStarButton />
|
|
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
);
|
2024-04-16 13:40:25 -07:00
|
|
|
};
|
2024-04-15 15:00:47 -07:00
|
|
|
export default Navbar;
|