| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 | {{/*  variables for enabling/disabling various features  */}}{{ $blogEnabled   := site.Params.features.blog.enable   | default false }}{{ $notesEnabled  := site.Params.features.notes.enable  | default false }}{{/*  keep backward compatibility for blog post  */}}{{ if site.Params.enableBlogPost }}  {{ $blogEnabled = true }}{{ end }}{{/* by default, don't use any logo */}}{{ $mainLogo := "" }}{{ $invertedLogo := "" }}{{/*  if custom logo has been provided, use them  */}}{{ if site.Params.logo.main }}  {{ $mainLogo = site.Params.logo.main }}{{ end }}{{ if site.Params.logo.inverted }}  {{ $invertedLogo = site.Params.logo.inverted }}{{ end }}{{/* resize the logos. don't resize svg because it is not supported */}}{{ if $mainLogo }}  {{ $mainLogo = resources.Get $mainLogo}}  {{ if and $mainLogo (ne $mainLogo.MediaType.SubType "svg") }}    {{ $mainLogo = $mainLogo.Resize "42x" }}  {{ end }}  {{ $mainLogo = $mainLogo.RelPermalink}}{{ end }}{{ if $invertedLogo }}  {{ $invertedLogo = resources.Get $invertedLogo}}  {{ if and $invertedLogo (ne $invertedLogo.MediaType.SubType "svg")}}    {{ $invertedLogo = $invertedLogo.Resize "42x" }}  {{ end }}  {{ $invertedLogo = $invertedLogo.RelPermalink}}{{ end }}{{ $customMenus := site.Params.customMenus }}{{ if (index site.Data site.Language.Lang).site.customMenus }}  {{ $customMenus = (index site.Data site.Language.Lang).site.customMenus }}{{ end }}{{ $sections := site.Data.sections }}{{ if (index site.Data site.Language.Lang).sections }}  {{ $sections = (index site.Data site.Language.Lang).sections }}{{ end }}<nav class="navbar navbar-expand-xl top-navbar initial-navbar" id="top-navbar">  <div class="container">    <a class="navbar-brand" href="{{ site.BaseURL | relLangURL }}">      {{ if $invertedLogo }}        <img src="{{ $invertedLogo }}" id="logo" alt="Logo">      {{ end }}      {{- site.Title -}}    </a>    <button      class="navbar-toggler navbar-dark"      id="navbar-toggler"      type="button"      data-toggle="collapse"      data-target="#top-nav-items"      aria-label="menu"    >      <span class="navbar-toggler-icon"></span>    </button>    <div class="collapse navbar-collapse" id="top-nav-items">      <ul class="navbar-nav ml-auto">        <li class="nav-item">          <a class="nav-link" href="#home">{{ i18n "home" }}</a>        </li>        {{ if $sections }}          {{ $sectionCount := 0}}          {{ range sort $sections "section.weight" }}            {{ if and (.section.enable) (.section.showOnNavbar)}}              {{ $sectionCount  = add $sectionCount 1}}              {{ if le $sectionCount 5 }}                <li class="nav-item">                  <a class="nav-link" href="#{{ partial "helpers/get-section-id.html" . }}">{{ .section.name }}</a>                </li>              {{ end }}            {{ end }}          {{- end }}          {{ if gt $sectionCount 5 }}          <li class="nav-item dropdown">            <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{i18n "more" }}</a>            <div class="dropdown-menu" aria-labelledby="navbarDropdown">                {{ $sectionCount := 0 }}                {{ range sort $sections "section.weight" }}                  {{ if and (.section.enable) (.section.showOnNavbar) }}                    {{ $sectionCount  = add $sectionCount 1}}                    {{ if gt $sectionCount 5 }}                      <a class="dropdown-item" href="#{{ partial "helpers/get-section-id.html" . }}">{{ .section.name }}</a>                    {{ end }}                  {{ end }}                {{- end }}              </div>            </li>          {{ end }}        {{- end }}        {{ $shouldAddSeparator:= partial "helpers/add-navbar-separator.html" . }}        {{ if $shouldAddSeparator }}          <div class="dropdown-divider" id="top-navbar-divider"></div>        {{ end }}        {{ if $blogEnabled }}          <li class="nav-item">            <a class="nav-link" id="blog-link" href="{{ "/posts" | relLangURL }}">{{ i18n "posts" }}</a>          </li>        {{ end }}        {{ if $notesEnabled }}          <li class="nav-item">            <a class="nav-link" id="note-link" href="{{ "/notes" | relLangURL }}">{{ i18n "notes" }}</a>          </li>        {{ end }}        {{ range $customMenus }}          <li class="nav-item">            <a class="nav-link" href="{{ .url }}">{{ .name }}</a>          </li>        {{ end }}        {{ if .IsTranslated }}          {{ partial "navigators/lang-selector.html" . }}        {{ end }}      </ul>    </div>  </div>  <!-- Store the logo information in a hidden img for the JS -->  {{ if $mainLogo }}    <img src="{{ $mainLogo }}" class="d-none" id="main-logo" alt="Logo">  {{ end }}  {{ if $invertedLogo }}    <img src="{{ $invertedLogo }}" class="d-none" id="inverted-logo" alt="Inverted Logo">  {{ end }}</nav>
 |