firq-dev-website/src/components/navbarEntry.astro

59 lines
966 B
Text
Raw Normal View History

2023-03-04 19:11:52 +01:00
---
export interface Props {
2023-03-09 11:44:18 +01:00
currentPage?: string
link: string
text: string
icon: string
2023-03-04 19:11:52 +01:00
}
2023-03-09 11:44:18 +01:00
const { icon, text, link, currentPage } = Astro.props
2023-03-04 19:11:52 +01:00
2023-03-09 11:44:18 +01:00
let currPage = ''
const slug = link.replace(new RegExp('/', 'g'), '')
2023-03-04 19:11:52 +01:00
2023-03-04 22:35:49 +01:00
if (currentPage === slug) {
2023-03-09 11:44:18 +01:00
currPage = 'current'
} else if (currentPage === 'home' && link === '/') {
currPage = 'current'
2023-03-04 19:11:52 +01:00
}
2023-03-04 22:35:49 +01:00
2023-03-09 11:44:18 +01:00
const fulllink = `/${slug}`
2023-03-04 19:11:52 +01:00
---
<li>
2023-03-09 11:44:18 +01:00
<a
href={fulllink}
rel="noopener noreferrer"
aria-label={text}
class={currPage}
>
<i class={icon}></i>
{text}
</a>
2023-03-04 19:11:52 +01:00
</li>
<style>
2023-03-09 11:44:18 +01:00
li {
align-items: center;
justify-content: center;
text-align: left;
display: flex;
width: 200px;
}
li > a {
color: white;
text-decoration: none;
justify-content: center;
align-items: center;
font-size: 1.4em;
height: 100%;
font-weight: bold;
}
li > a:hover {
color: var(--c-purplepink);
}
.current {
color: var(--c-darkpurple);
}
</style>