mirror of
https://github.com/hex248/ob248.com.git
synced 2026-02-08 02:33:02 +00:00
improved current page handling
This commit is contained in:
@@ -2,15 +2,53 @@
|
||||
import NavLink from "./NavLink.astro";
|
||||
|
||||
const { currentPage } = Astro.props;
|
||||
|
||||
const pages = [
|
||||
{ title: "Home", path: "/" },
|
||||
{ title: "About", path: "/about" },
|
||||
];
|
||||
---
|
||||
|
||||
<style>
|
||||
.cancel-button {
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--ayu-red-500);
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<header class="">
|
||||
<div class="w-full flex gap-4 px-4 py-2 border-b-1 border-ayu-gutter">
|
||||
<h1 class="text-2xl text-ayu-red-500">oliver bryan</h1>
|
||||
</div>
|
||||
<!-- nav: -->
|
||||
<div class="w-full flex gap-4 px-4 py-2 border-b-1 border-ayu-gutter">
|
||||
<NavLink currentPage={currentPage} title="home" href="/" />
|
||||
<NavLink currentPage={currentPage} title="about" href="/about" />
|
||||
<div
|
||||
class="w-full flex gap-4 px-4 py-2 border-b-1 border-ayu-gutter items-center"
|
||||
>
|
||||
{
|
||||
pages.map((page) => (
|
||||
<NavLink
|
||||
currentPage={currentPage}
|
||||
title={page.title}
|
||||
href={page.path}
|
||||
/>
|
||||
))
|
||||
}
|
||||
|
||||
{
|
||||
!pages.find((page) => page.path === currentPage.path) && (
|
||||
<span class="flex items-center justify-start gap-2">
|
||||
<span class="text-ayu-gutter">| {currentPage.path} </span>
|
||||
<button
|
||||
class="cancel-button flex items-center justify-center"
|
||||
type="button"
|
||||
onclick="window.location.href='/'"
|
||||
>
|
||||
<span class="text-2xl leading-none">×</span>
|
||||
</button>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
Reference in New Issue
Block a user