{{ $cover := and
    (.HasShortcode "blocks/cover")
    (not .Site.Params.ui.navbar_translucent_over_cover_disable)
-}}
{{ $baseURL := urls.Parse $.Site.Params.Baseurl -}}

<nav class="td-navbar js-navbar-scroll
      {{- if $cover }} td-navbar-cover td-navbar-transparent {{- end }}"
      {{- if eq (.Param "ui.navbar_theme") "dark" }} data-bs-theme="dark" {{- end }}>
<div class="td-navbar-container container-fluid flex-column flex-md-row">
  <a class="navbar-brand" href="{{ .Site.Home.RelPermalink }}">
    <span class="navbar-brand__logo navbar-logo">
      {{- if ne .Site.Params.ui.navbar_logo false -}}
        {{ with resources.Get "icons/logo.svg" -}}
          {{ ( . | minify).Content | safeHTML -}}
        {{ end -}}
      {{ end -}}
    </span>
  </a>
  <div class="td-navbar__main td-navbar-nav-scroll td-navbar-nav-scroll--indicator" id="main_navbar">
    <div class="scroll-indicator scroll-left"></div>
    <ul class="navbar-nav">
      {{ $p := . -}}
      {{ $s := .Site -}}
      {{ range .Site.Menus.main -}}
			<li class="nav-item">
				{{ if .HasChildren }}
				<!-- Menu items with children -->
				<button class="btn btn-link nav-link dropdown-toggle d-flex align-items-center" type="button" data-bs-toggle="dropdown" aria-expanded="false">
					{{- .Pre -}}
					<span>{{ .Name }}</span>
				</button>
				<ul class="dropdown-menu">
					{{ $children := .Children.ByWeight -}}
					{{ $bannedItems := slice -}}

					{{ if eq .Identifier "doc" -}}
					{{ $releasePages := partial "releasePages.html" (dict "site" $s) -}}
					{{ range $releasePages.eol -}}
					{{ $bannedItems = $bannedItems | append .LinkTitle -}}
					{{ end -}}
					{{ end -}}

					{{ if eq .Identifier "releases" -}}
					{{ $downloadPages := partial "downloadPages.html" (dict "site" $s) -}}
					{{ range $downloadPages.eol -}}
					{{ $bannedItems = $bannedItems | append .LinkTitle -}}
					{{ end -}}
					{{ end -}}

					{{ range $children -}}
					{{ if not (in $bannedItems .Name) -}}
					<li><a class="dropdown-item" href="{{ .URL }}">{{ .Name }}</a></li>
					{{- end -}}
					{{- end -}}
				</ul>
				{{ else -}}
				<!-- Menu items without children -->
				{{ $topHidden := false }}
				{{ if .Page }}
				{{ $topHidden = .Page.Params.top_hidden | default false }}
				{{ else }}
				{{ $topHidden = .Params.top_hidden | default false }}
				{{ end }}
				{{ if not $topHidden }}
					{{ $active := or ($p.IsMenuCurrent "main" .) ($p.HasMenuCurrent "main" .) -}}
					{{ $href := "" -}}
					{{ with .Page -}}
						{{ $active = or $active ( $.IsDescendant .) -}}
						{{ $href = .RelPermalink -}}
					{{ else -}}
						{{ $href = .URL | relLangURL -}}
					{{ end -}}
					{{ $isExternal := ne $baseURL.Host (urls.Parse .URL).Host -}}
					<a {{/**/ -}}
						class="nav-link {{- if $active }} active {{- end }}" {{/**/ -}}
						href="{{ $href }}"
						{{- if $isExternal }} target="_blank" rel="noopener" {{- end -}}
					>
							{{- .Pre -}}
							<span>{{ .Name }}</span>
							{{- .Post -}}
					</a>
				{{ end -}}
				{{ end -}}
			</li>
      {{ end -}}
      <!-- Other navbar items -->
      {{ if .Site.Params.versions -}}
      <li class="nav-item td-navbar__version-menu">
        {{ partial "navbar-version-selector.html" . -}}
      </li>
      {{ end -}}
      {{ if (gt (len .Site.Home.Translations) 0) -}}
      <li class="nav-item td-navbar__lang-menu">
        {{ partial "navbar-lang-selector.html" . -}}
      </li>
      {{ end -}}
      {{- $darkMode := partialCached "dark-mode-config.html" "dark-mode-global" -}}
      {{ if $darkMode.showMenu -}}
      <li class="nav-item td-navbar__light-dark-menu">
        {{ partial "theme-toggler" . }}
      </li>
      {{ end -}}
    </ul>
    <div class="scroll-indicator scroll-right"></div>
  </div>
  <div class="td-navbar__search d-none d-lg-block">
    {{ partial "search-input.html" . }}
  </div>
</div>
</nav>