2025-06-18 07:46:59 -04:00
|
|
|
---
|
2025-11-25 10:04:05 -05:00
|
|
|
import { metaData, API_URL } from "../config";
|
2025-06-18 07:46:59 -04:00
|
|
|
import { Icon } from "astro-icon/components";
|
2025-11-26 10:43:34 -05:00
|
|
|
import { requireAuthHook } from "@/hooks/requireAuthHook";
|
|
|
|
|
import { padlockIconSvg, userIconSvg, externalLinkIconSvg } from "@/utils/navAssets";
|
|
|
|
|
import "@/assets/styles/nav.css";
|
2025-06-18 07:46:59 -04:00
|
|
|
|
2025-11-26 10:43:34 -05:00
|
|
|
const user = await requireAuthHook(Astro);
|
2025-11-28 09:07:55 -05:00
|
|
|
const hostHeader = Astro.request?.headers?.get('host') || '';
|
|
|
|
|
const host = hostHeader.split(':')[0];
|
|
|
|
|
import { getSubsiteByHost } from '../utils/subsites.js';
|
|
|
|
|
import { getSubsiteByPath } from '../utils/subsites.js';
|
|
|
|
|
const isReq = getSubsiteByHost(host)?.short === 'req' || getSubsiteByPath(Astro.url.pathname)?.short === 'req';
|
|
|
|
|
// Nav is the standard site navigation — whitelabel logic belongs in SubNav
|
2025-11-26 10:43:34 -05:00
|
|
|
const isLoggedIn = Boolean(user);
|
|
|
|
|
const userDisplayName = user?.user ?? null;
|
2025-11-25 10:04:05 -05:00
|
|
|
|
2025-07-17 06:55:01 -04:00
|
|
|
const navItems = [
|
|
|
|
|
{ label: "Home", href: "/" },
|
|
|
|
|
{ label: "Radio", href: "/radio" },
|
2025-11-26 09:17:30 -05:00
|
|
|
{ label: "Memes", href: "/memes" },
|
2025-11-26 10:43:34 -05:00
|
|
|
{ label: "TRip", href: "/TRip", auth: true, icon: "pirate" },
|
2025-11-26 09:17:30 -05:00
|
|
|
{ label: "Lighting", href: "/lighting", auth: true },
|
2025-12-03 13:27:37 -05:00
|
|
|
{ label: "Discord Logs", href: "/discord-logs", auth: true },
|
2025-11-25 10:04:05 -05:00
|
|
|
{ label: "Status", href: "https://status.boatson.boats", icon: "external" },
|
|
|
|
|
{ label: "Git", href: "https://kode.boatson.boats", icon: "external" },
|
2025-11-26 09:17:30 -05:00
|
|
|
{ label: "Login", href: "/login", guestOnly: true },
|
2025-11-25 10:04:05 -05:00
|
|
|
...(isLoggedIn ? [{ label: "Logout", href: "#logout", onclick: "handleLogout()" }] : []),
|
2025-07-17 06:55:01 -04:00
|
|
|
];
|
|
|
|
|
|
2025-11-26 09:17:30 -05:00
|
|
|
const visibleNavItems = navItems.filter((item) => {
|
|
|
|
|
if (item.auth && !isLoggedIn) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.guestOnly && isLoggedIn) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
|
2025-07-17 06:55:01 -04:00
|
|
|
const currentPath = Astro.url.pathname;
|
2025-11-25 10:04:05 -05:00
|
|
|
|
2025-06-18 07:46:59 -04:00
|
|
|
---
|
2025-11-22 12:12:56 -05:00
|
|
|
|
2025-11-25 13:05:37 -05:00
|
|
|
<script src="/scripts/nav-controls.js" defer data-api-url={API_URL}></script>
|
2025-11-22 12:12:56 -05:00
|
|
|
|
2025-12-05 14:21:52 -05:00
|
|
|
<nav class="w-full px-4 sm:px-6 py-3 sticky top-0 z-50 backdrop-blur-xl bg-white/75 dark:bg-[#0a0a0a]/75 border-b border-neutral-200/40 dark:border-neutral-800/40 shadow-sm shadow-neutral-900/5 dark:shadow-black/20">
|
2025-11-22 12:12:56 -05:00
|
|
|
<div class="max-w-7xl mx-auto">
|
2025-11-26 09:17:30 -05:00
|
|
|
<div class="nav-bar-row flex items-center gap-4 justify-between">
|
2025-11-22 12:12:56 -05:00
|
|
|
<!-- Logo/Brand -->
|
|
|
|
|
<a
|
2025-11-28 09:07:55 -05:00
|
|
|
href="/"
|
2025-12-05 14:21:52 -05:00
|
|
|
class="text-xl sm:text-2xl font-bold tracking-tight bg-gradient-to-r from-neutral-900 to-neutral-600 dark:from-white dark:to-neutral-400 bg-clip-text text-transparent whitespace-nowrap hover:opacity-80 transition-opacity font-['IBM_Plex_Sans',sans-serif]">
|
2025-11-28 09:07:55 -05:00
|
|
|
{metaData.title}
|
|
|
|
|
</a>
|
2025-11-22 12:12:56 -05:00
|
|
|
|
|
|
|
|
<!-- Desktop Navigation -->
|
2025-11-26 09:17:30 -05:00
|
|
|
<div class="desktop-nav flex items-center">
|
|
|
|
|
<ul class="desktop-nav-list">
|
|
|
|
|
{visibleNavItems.map((item) => {
|
2025-11-22 12:12:56 -05:00
|
|
|
const isExternal = item.href?.startsWith("http");
|
|
|
|
|
const isAuthedPath = item.auth ?? false;
|
|
|
|
|
const normalize = (url) => (url || '/').replace(/\/+$/, '') || '/';
|
|
|
|
|
const normalizedCurrent = normalize(currentPath);
|
|
|
|
|
const normalizedHref = normalize(item.href);
|
|
|
|
|
const isActive = !isExternal && (
|
|
|
|
|
normalizedHref === '/'
|
|
|
|
|
? normalizedCurrent === '/'
|
|
|
|
|
: normalizedCurrent === normalizedHref || normalizedCurrent.startsWith(normalizedHref + '/')
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<li>
|
|
|
|
|
<a
|
|
|
|
|
href={item.href}
|
|
|
|
|
class={isActive
|
2025-12-05 14:21:52 -05:00
|
|
|
? "flex items-center gap-0.5 px-3 py-1.5 rounded-lg text-[13px] font-semibold transition-all duration-200 text-white bg-neutral-900 dark:bg-white dark:text-neutral-900 shadow-sm font-['IBM_Plex_Sans',sans-serif]"
|
|
|
|
|
: "flex items-center gap-0.5 px-3 py-1.5 rounded-lg text-[13px] font-medium transition-all duration-200 text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-white hover:bg-neutral-100 dark:hover:bg-neutral-800/60 font-['IBM_Plex_Sans',sans-serif]"
|
2025-11-22 12:12:56 -05:00
|
|
|
}
|
|
|
|
|
target={isExternal ? "_blank" : undefined}
|
|
|
|
|
rel={(isExternal || isAuthedPath) ? "external" : undefined}
|
2025-11-25 10:04:05 -05:00
|
|
|
onclick={item.onclick}
|
2025-11-22 12:12:56 -05:00
|
|
|
>
|
|
|
|
|
{item.label}
|
2025-11-25 10:04:05 -05:00
|
|
|
{item.icon === "external" && (
|
|
|
|
|
<span class="inline-flex ml-0.5" aria-hidden="true" set:html={externalLinkIconSvg}></span>
|
|
|
|
|
)}
|
|
|
|
|
{item.icon === "padlock" && (
|
|
|
|
|
<span class="inline-flex" aria-hidden="true" set:html={padlockIconSvg}></span>
|
2025-11-22 12:12:56 -05:00
|
|
|
)}
|
2025-11-26 09:17:30 -05:00
|
|
|
{item.icon === "pirate" && (
|
|
|
|
|
<span class="inline-flex ml-1" role="img" aria-label="Pirate flag">🏴☠️</span>
|
|
|
|
|
)}
|
2025-11-22 12:12:56 -05:00
|
|
|
</a>
|
2025-07-17 06:55:01 -04:00
|
|
|
</li>
|
2025-11-22 12:12:56 -05:00
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</ul>
|
|
|
|
|
|
2025-11-26 10:43:34 -05:00
|
|
|
{isLoggedIn && userDisplayName && (
|
|
|
|
|
<div class="nav-user-inline" title={`Logged in as ${userDisplayName}`}>
|
|
|
|
|
<span class="nav-user-inline__icon" aria-hidden="true" set:html={userIconSvg}></span>
|
|
|
|
|
<span class="nav-user-inline__name">{userDisplayName}</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
2025-11-22 12:12:56 -05:00
|
|
|
<!-- Theme Toggle Desktop -->
|
|
|
|
|
<button
|
|
|
|
|
aria-label="Toggle theme"
|
|
|
|
|
type="button"
|
2025-11-26 09:17:30 -05:00
|
|
|
class="flex items-center justify-center w-8 h-8 rounded-md hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors"
|
2025-11-22 12:12:56 -05:00
|
|
|
onclick="toggleTheme()"
|
|
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
name="fa6-solid:circle-half-stroke"
|
2025-11-22 21:41:41 -05:00
|
|
|
class="h-4 w-4 text-[#1c1c1c] dark:text-[#D4D4D4]"
|
2025-11-22 12:12:56 -05:00
|
|
|
/>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2025-07-17 10:38:58 -04:00
|
|
|
|
2025-11-22 12:12:56 -05:00
|
|
|
<!-- Mobile Menu Button -->
|
|
|
|
|
<div class="mobile-nav flex items-center gap-2">
|
|
|
|
|
<!-- Theme Toggle Mobile (visible) -->
|
2025-07-17 06:55:01 -04:00
|
|
|
<button
|
|
|
|
|
aria-label="Toggle theme"
|
|
|
|
|
type="button"
|
2025-11-22 12:12:56 -05:00
|
|
|
class="flex items-center justify-center w-9 h-9 rounded-lg hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors"
|
2025-07-17 06:55:01 -04:00
|
|
|
onclick="toggleTheme()"
|
|
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
name="fa6-solid:circle-half-stroke"
|
2025-11-22 12:12:56 -05:00
|
|
|
class="h-5 w-5 text-[#1c1c1c] dark:text-[#D4D4D4]"
|
2025-07-17 06:55:01 -04:00
|
|
|
/>
|
|
|
|
|
</button>
|
2025-11-22 12:12:56 -05:00
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
id="mobile-menu-btn"
|
|
|
|
|
aria-label="Toggle menu"
|
|
|
|
|
type="button"
|
|
|
|
|
class="flex items-center justify-center w-9 h-9 rounded-lg hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors"
|
|
|
|
|
>
|
|
|
|
|
<svg id="menu-icon" class="w-6 h-6 text-neutral-700 dark:text-neutral-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
|
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path>
|
|
|
|
|
</svg>
|
|
|
|
|
<svg id="close-icon" class="w-6 h-6 text-neutral-700 dark:text-neutral-300" style="display: none;" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
|
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
|
|
|
|
|
</svg>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Mobile Navigation Menu -->
|
|
|
|
|
<div
|
|
|
|
|
id="mobile-menu"
|
|
|
|
|
class="mobile-menu-dropdown md:hidden"
|
|
|
|
|
>
|
2025-11-26 10:43:34 -05:00
|
|
|
{isLoggedIn && userDisplayName && (
|
|
|
|
|
<div class="nav-user-inline nav-user-inline--mobile" title={`Logged in as ${userDisplayName}`}>
|
|
|
|
|
<span class="nav-user-inline__icon" aria-hidden="true" set:html={userIconSvg}></span>
|
|
|
|
|
<span class="nav-user-inline__name">{userDisplayName}</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2025-11-22 12:12:56 -05:00
|
|
|
<ul class="flex flex-col gap-1 py-4">
|
2025-11-26 09:17:30 -05:00
|
|
|
{visibleNavItems.map((item) => {
|
2025-11-22 12:12:56 -05:00
|
|
|
const isExternal = item.href?.startsWith("http");
|
|
|
|
|
const isAuthedPath = item.auth ?? false;
|
|
|
|
|
const normalize = (url) => (url || '/').replace(/\/+$/, '') || '/';
|
|
|
|
|
const normalizedCurrent = normalize(currentPath);
|
|
|
|
|
const normalizedHref = normalize(item.href);
|
|
|
|
|
const isActive = !isExternal && (
|
|
|
|
|
normalizedHref === '/'
|
|
|
|
|
? normalizedCurrent === '/'
|
|
|
|
|
: normalizedCurrent === normalizedHref || normalizedCurrent.startsWith(normalizedHref + '/')
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<li>
|
|
|
|
|
<a
|
|
|
|
|
href={item.href}
|
|
|
|
|
class={isActive
|
2025-11-28 09:07:55 -05:00
|
|
|
? "flex items-center gap-0 px-4 py-3 rounded-lg text-base font-medium transition-all duration-200 text-white"
|
2025-11-25 10:04:05 -05:00
|
|
|
: "flex items-center gap-0 px-4 py-3 rounded-lg text-base font-medium transition-all duration-200 text-neutral-700 dark:text-neutral-300 hover:bg-neutral-100 dark:hover:bg-neutral-800"
|
2025-11-22 12:12:56 -05:00
|
|
|
}
|
2025-11-28 09:07:55 -05:00
|
|
|
style={isActive ? `background: #111827` : undefined}
|
2025-11-22 12:12:56 -05:00
|
|
|
target={isExternal ? "_blank" : undefined}
|
|
|
|
|
rel={(isExternal || isAuthedPath) ? "external" : undefined}
|
2025-11-25 10:04:05 -05:00
|
|
|
onclick={item.onclick}
|
2025-11-22 12:12:56 -05:00
|
|
|
>
|
|
|
|
|
<span>{item.label}</span>
|
2025-11-25 10:04:05 -05:00
|
|
|
{item.icon === "external" && (
|
|
|
|
|
<span class="inline-flex ml-0.5" aria-hidden="true" set:html={externalLinkIconSvg}></span>
|
|
|
|
|
)}
|
|
|
|
|
{item.icon === "padlock" && (
|
|
|
|
|
<span class="inline-flex" aria-hidden="true" set:html={padlockIconSvg}></span>
|
2025-11-22 12:12:56 -05:00
|
|
|
)}
|
2025-11-26 09:17:30 -05:00
|
|
|
{item.icon === "pirate" && (
|
|
|
|
|
<span class="inline-flex ml-1" role="img" aria-label="Pirate flag">🏴☠️</span>
|
|
|
|
|
)}
|
2025-11-22 12:12:56 -05:00
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
2025-06-18 07:46:59 -04:00
|
|
|
</div>
|
|
|
|
|
</nav>
|