{{/*

  A version of the navbar.html partial in Docsy, only modified
	to include the spec version, which is calculated using an
  inline `version-string` partial.

*/}}

{{ $cover := .HasShortcode "blocks/cover" }}
<nav class="js-navbar-scroll navbar navbar-expand navbar-light {{ if $cover}} td-navbar-cover {{ end }}flex-column flex-md-row td-navbar">
        <a class="navbar-brand" href="{{ .Site.Home.RelPermalink }}">
		<span class="navbar-logo">{{ with resources.Get "icons/logo.svg" }}{{ ( . | minify).Content | safeHTML }}{{ end }}</span><span class="font-weight-bold">specification</span><span class="navbar-version"> &mdash; {{ partial "version-string" . }}</span>
	</a>
	<div class="td-navbar-nav-scroll ml-md-auto" id="main_navbar">
		<ul class="navbar-nav mt-2 mt-lg-0">

			<li class="nav-item mr-4 mb-2 mb-lg-0"><a href="https://matrix.org/foundation/">Foundation</a>
			</li>

      <li class="nav-item mr-4 mb-2 mb-lg-0"><a href="https://matrix.org/faq/">FAQs</a>
			</li>

      <li class="nav-item mr-4 mb-2 mb-lg-0"><a href="https://matrix.org/blog/posts">Blog</a>
      </li>

			{{ if  .Site.Params.versions }}
			<li class="nav-item dropdown d-none d-lg-block">
				{{ partial "navbar-version-selector.html" . }}
			</li>
			{{ end }}
			{{ if  (gt (len .Site.Home.Translations) 0) }}
			<li class="nav-item dropdown d-none d-lg-block">
				{{ partial "navbar-lang-selector.html" . }}
			</li>
			{{ end }}
		</ul>
	</div>
	<div class="navbar-nav d-none d-lg-block">{{ partial "search-input.html" . }}</div>
</nav>


{{ define "partials/version-string" }}
    {{ $ret := "unstable version"}}

    {{ $status := .Site.Params.version.status }}

    {{ if ne $status "unstable"}}
        {{ $path := path.Join "changelogs" }}

        {{/* produces a string similar to "version v1.5" */}}
        {{ $ret = delimit (slice "version v" .Site.Params.version.major "." .Site.Params.version.minor) "" }}
    {{ end }}

    {{ return $ret }}
{{ end }}
