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";
|
import NavLink from "./NavLink.astro";
|
||||||
|
|
||||||
const { currentPage } = Astro.props;
|
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="">
|
<header class="">
|
||||||
<div class="w-full flex gap-4 px-4 py-2 border-b-1 border-ayu-gutter">
|
<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>
|
<h1 class="text-2xl text-ayu-red-500">oliver bryan</h1>
|
||||||
</div>
|
</div>
|
||||||
<!-- nav: -->
|
<div
|
||||||
<div class="w-full flex gap-4 px-4 py-2 border-b-1 border-ayu-gutter">
|
class="w-full flex gap-4 px-4 py-2 border-b-1 border-ayu-gutter items-center"
|
||||||
<NavLink currentPage={currentPage} title="home" href="/" />
|
>
|
||||||
<NavLink currentPage={currentPage} title="about" href="/about" />
|
{
|
||||||
|
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>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ const { currentPage, title, href } = Astro.props;
|
|||||||
|
|
||||||
<a
|
<a
|
||||||
href={href}
|
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
|
>{title}</a
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -32,7 +32,12 @@ const { metadata } = Astro.props;
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<Layout currentPage="projects">
|
<Layout
|
||||||
|
currentPage={{
|
||||||
|
title: `${metadata.title}`,
|
||||||
|
path: `projects/${metadata.slug}`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<div class="text-md">
|
<div class="text-md">
|
||||||
<h1 class="text-2xl text-ayu-accent mb-2">
|
<h1 class="text-2xl text-ayu-accent mb-2">
|
||||||
{metadata.title}
|
{metadata.title}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Layout from "../layouts/Layout.astro";
|
|||||||
import TimeSince from "../components/TimeSince.astro";
|
import TimeSince from "../components/TimeSince.astro";
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout currentPage="about">
|
<Layout currentPage={{ title: "about", path: "/about" }}>
|
||||||
<div class="text-md">
|
<div class="text-md">
|
||||||
<p>
|
<p>
|
||||||
AGE: <TimeSince
|
AGE: <TimeSince
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ const projects: ProjectMetadata[] = Object.values(
|
|||||||
.sort((a, b) => parseDate(b.date).getTime() - parseDate(a.date).getTime());
|
.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> -->
|
<!-- <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">
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-4">
|
||||||
|
|||||||
Reference in New Issue
Block a user