2024-12-23 21:18:55 +00:00
|
|
|
---
|
|
|
|
import { SITE } from "@consts";
|
2025-02-16 18:17:29 +00:00
|
|
|
import Button from "@components/Button.astro";
|
2025-02-17 00:14:50 +00:00
|
|
|
import { Icon } from "astro-icon/components";
|
2025-08-22 22:57:31 +01:00
|
|
|
import { getCollection } from "astro:content";
|
2025-02-13 16:55:09 +00:00
|
|
|
|
|
|
|
const pathname = new URL(Astro.request.url).pathname;
|
|
|
|
const currentPath = pathname.replace(/\/$/, "");
|
2025-08-22 22:57:31 +01:00
|
|
|
|
|
|
|
const allPosts = (await getCollection("posts")).filter(
|
|
|
|
(post) => !post.data.draft,
|
|
|
|
);
|
|
|
|
const hasPosts = allPosts.length > 0;
|
|
|
|
|
|
|
|
const allProjects = (await getCollection("projects")).filter(
|
|
|
|
(post) => !post.data.draft,
|
|
|
|
);
|
|
|
|
const hasProjects = allProjects.length > 0;
|
|
|
|
|
|
|
|
const filteredNavLinks = SITE.NAVLINKS.filter((link) => {
|
|
|
|
if (link.href === "/posts") {
|
|
|
|
return hasPosts;
|
|
|
|
}
|
|
|
|
if (link.href === "/projects") {
|
|
|
|
return hasProjects;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
2024-12-23 21:18:55 +00:00
|
|
|
---
|
|
|
|
|
2025-02-13 18:55:50 +00:00
|
|
|
<header class="mx-auto w-full">
|
2025-02-15 23:08:31 +00:00
|
|
|
<nav class="flex w-full justify-between">
|
2025-06-04 18:51:58 +01:00
|
|
|
<a href="/" aria-label={SITE.TITLE}>
|
2025-03-02 18:07:22 +00:00
|
|
|
<Icon
|
|
|
|
name="icon"
|
2025-08-22 11:03:09 +01:00
|
|
|
class="hover:text-tertiary h-8 w-auto rounded-sm transition-colors duration-500 ease-in-out"
|
2025-03-02 18:07:22 +00:00
|
|
|
/>
|
|
|
|
</a>
|
2025-02-15 23:08:31 +00:00
|
|
|
<ul class="flex w-fit flex-row items-center gap-4">
|
2025-02-12 13:03:43 +00:00
|
|
|
{
|
2025-08-22 22:57:31 +01:00
|
|
|
filteredNavLinks.map((link) => {
|
2025-02-13 16:55:09 +00:00
|
|
|
let linkHref = link.href.replace(/\/$/, "");
|
|
|
|
const isActive = currentPath.startsWith(linkHref);
|
2025-08-22 22:57:31 +01:00
|
|
|
|
2025-02-13 16:55:09 +00:00
|
|
|
return (
|
2025-03-08 09:48:04 +00:00
|
|
|
<li class="text-tertiary hover:text-secondary focus:text-secondary font-medium transition-colors duration-300 focus:outline-hidden">
|
2025-02-13 16:55:09 +00:00
|
|
|
<a
|
|
|
|
href={link.href}
|
2025-03-02 18:07:22 +00:00
|
|
|
class:list={[
|
|
|
|
isActive
|
|
|
|
? "text-secondary hover:text-tertiary transition-colors duration-300"
|
|
|
|
: null,
|
|
|
|
]}
|
2025-02-13 16:55:09 +00:00
|
|
|
>
|
|
|
|
{link.name}
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
);
|
|
|
|
})
|
2025-02-12 13:03:43 +00:00
|
|
|
}
|
2025-02-16 20:03:52 +00:00
|
|
|
<li>
|
|
|
|
<Button href={`mailto:${SITE.EMAIL}`} link="Email" />
|
|
|
|
</li>
|
2025-02-12 13:03:43 +00:00
|
|
|
</ul>
|
|
|
|
</nav>
|
2024-12-23 21:18:55 +00:00
|
|
|
</header>
|