---
import Icon from 'astro-iconify'
import type { Link } from '../constants/links'

export interface Props {
  links: Link[]
}

let { links } = Astro.props

if (Astro.url.pathname !== '/') {
  links = [
    {
      url: '/',
      icon: 'home',
    },
  ].concat(links)
}
---

<nav>
  <div id="wrapper">
    {
      links
        .filter((link) => link.url !== '')
        .map((link) => (
          <a href={link.url}>
            <Icon pack={link.set ?? 'mdi'} name={link.icon} />{' '}
            {link.text ?? link.icon}
          </a>
        ))
    }
  </div>
</nav>

<style>
  nav {
    background: var(--ayo-gradient);
    display: flex;
    margin: 0 auto;
  }
  nav a {
    display: inline-block;
    text-decoration: underline;
    color: var(--text-color-light);
    padding: 0.5em 1em;
    font-size: var(--font-size-sm);
  }
  nav a:hover {
    color: var(--color-brand-complement);
  }

  nav a svg {
    width: 1.5rem;
  }

  #wrapper {
    flex: 1;
    max-width: var(--content-width);
    margin: 0 auto;
    text-align: right;
  }

  @media only screen and (max-device-width: 360px) {
    #wrapper {
      text-align: center;
    }
    nav a {
      padding: 0.5em;
    }
  }

  a {
    font-weight: bold;
  }
</style>
