homepage/src/components/nav.js

59 lines
1.7 KiB
JavaScript
Raw Normal View History

2020-07-29 01:12:36 +00:00
import React from 'react'
import * as navStyles from './nav.module.css'
2020-07-29 01:12:36 +00:00
import { Link } from 'gatsby'
import { StaticImage } from "gatsby-plugin-image"
2019-12-11 21:34:32 +00:00
let pages = [
2020-07-29 01:12:36 +00:00
['home', '/', navStyles.desktopOnly],
['zeiten & location', '/treff/', ''],
['events', '/events/', ''],
['über uns', '/about/', ''],
['kontakt', '/kontakt/', ''],
['verein', '/verein/', ''],
['supporte uns', '/support/', ''],
2019-12-11 21:34:32 +00:00
]
export default function Nav({ path }) {
// nav items should always be active in the staticly generated html
2020-07-29 01:12:36 +00:00
const isSSR = typeof window === 'undefined'
const activeClasses = link =>
2020-07-29 01:12:36 +00:00
isSSR && path === link ? ' ' + navStyles.navItemActive : ''
return (
<>
2020-01-23 21:06:44 +00:00
<header className={navStyles.header}>
<Link to="/">
<div className={navStyles.headerContent}>
<span className={navStyles.logoContainer}>
<StaticImage
className={navStyles.logo}
src="../images/logo_ctdo.svg"
alt="CTDO-Logo"
loading="eager"
placeholder="none"
/>
</span>
<span>
<span className={navStyles.chaos}>Chaostreff</span> Dortmund
</span>
</div>
</Link>
2020-01-23 21:06:44 +00:00
</header>
<nav className={navStyles.nav}>
<div className={navStyles.navContent}>
{pages.map(([title, link, device]) => (
<Link
key={title}
2020-07-29 01:12:36 +00:00
className={navStyles.navItem + activeClasses(link) + ' ' + device}
activeClassName={navStyles.navItemActive}
2020-07-29 01:12:36 +00:00
to={`${link}`}
>
{title}
</Link>
))}
</div>
2020-01-23 21:06:44 +00:00
</nav>
</>
)
}