feat(astro): add navigation component

This commit is contained in:
Stefan Imhoff
2023-02-23 19:53:03 +01:00
parent 407169074e
commit 5240bf9be8
2 changed files with 46 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
---
import navigation from '../data/navigation.json';
const currentPath = new URL(Astro.request.url).pathname;
---
<nav
class="navigation col-span-16 col-start-2 self-center md:col-span-14 md:col-start-3"
role="navigation"
>
<ul class="navigation-list flex flex-wrap">
{
navigation.map(({ title, url }) => (
<li class="navigation-list-item mie-[10px] xs:mie-[15px]">
<a
class={`navigation-item-link text-3 font-light decoration-4 underline-offset-auto hover:underline hover:decoration-shibui-900/20 dark:hover:decoration-shibui-100/20 ${
currentPath === url &&
'active underline !decoration-accent decoration-4'
}`}
href={url}
>
{title}
</a>
</li>
))
}
</ul>
</nav>

18
src/data/navigation.json Normal file
View File

@@ -0,0 +1,18 @@
[
{
"title": "Home",
"url": "/"
},
{
"title": "About",
"url": "/about/"
},
{
"title": "Journal",
"url": "/journal/"
},
{
"title": "Projects",
"url": "/projects/"
}
]