mirror of
https://github.com/hex248/ob248.com.git
synced 2026-02-07 18:23:04 +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>
|
||||
|
||||
@@ -13,6 +13,6 @@ const { currentPage, title, href } = Astro.props;
|
||||
|
||||
<a
|
||||
href={href}
|
||||
class={`nav-link ${currentPage.toLowerCase() === title.toLowerCase() ? "text-ayu-accent font-bold" : ""}`}
|
||||
class={`nav-link ${currentPage.path === href ? "text-ayu-accent font-bold" : ""}`}
|
||||
>{title}</a
|
||||
>
|
||||
|
||||
@@ -32,7 +32,12 @@ const { metadata } = Astro.props;
|
||||
}
|
||||
</style>
|
||||
|
||||
<Layout currentPage="projects">
|
||||
<Layout
|
||||
currentPage={{
|
||||
title: `${metadata.title}`,
|
||||
path: `projects/${metadata.slug}`,
|
||||
}}
|
||||
>
|
||||
<div class="text-md">
|
||||
<h1 class="text-2xl text-ayu-accent mb-2">
|
||||
{metadata.title}
|
||||
|
||||
@@ -3,7 +3,7 @@ import Layout from "../layouts/Layout.astro";
|
||||
import TimeSince from "../components/TimeSince.astro";
|
||||
---
|
||||
|
||||
<Layout currentPage="about">
|
||||
<Layout currentPage={{ title: "about", path: "/about" }}>
|
||||
<div class="text-md">
|
||||
<p>
|
||||
AGE: <TimeSince
|
||||
|
||||
@@ -67,7 +67,7 @@ const projects: ProjectMetadata[] = Object.values(
|
||||
.sort((a, b) => parseDate(b.date).getTime() - parseDate(a.date).getTime());
|
||||
---
|
||||
|
||||
<Layout currentPage="home">
|
||||
<Layout currentPage={{ title: "home", path: "/" }}>
|
||||
<!-- <h1 class="text-2xl font-medium mb-4">projects:</h1> -->
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-4">
|
||||
|
||||
Reference in New Issue
Block a user