<header class="header">
  <a href="{{ .Site.BaseURL }}" class="header-logo">
    <img src="/static/img/logo-arbejdsfaellesskabet.svg">
  </a>

  <nav>
    <ul>
      {{ $currentPage := . }}
      {{ range .Site.Menus.main }}
        <li class="{{ if (or ($currentPage.HasMenuCurrent "main" .) ($currentPage.IsMenuCurrent "main" .))}}active{{ end }}">
          <a href="{{ .URL | absURL }}">{{ .Name }}</a>
        </li>
      {{ end }}
    </ul>
  </nav>
</header>

{{ range .Site.Menus.main }}
  {{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }}
    <ul class="header-submenu">
      {{ if and ($currentPage.IsMenuCurrent "main" .) (.HasChildren) }}
        <li class="active">
          <a href="{{ .URL | absURL }}">{{ .Name }}</a>
        </li>
      {{ end }}
      {{ if and ($currentPage.HasMenuCurrent "main" .) (not (eq $currentPage.Name .Name)) }}
        <li>
          <a href="{{ .URL | absURL  }}">{{ .Name }}</a>
        </li>
      {{ end }}
      {{ if .HasChildren }}
        {{ range .Children }}
        <li class="{{ if $currentPage.IsMenuCurrent "main" . }}active{{ end }}">
          <a href="{{ .URL | absURL }}">{{ .Name }}</a>
        </li>
        {{ end }}
      {{ end }}
    </ul>
  {{ end }}
{{ end }}
