| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 | {{ $current_page := . }}{{ $show_logo := site.Params.main_menu.show_logo | default true }}<nav class="navbar navbar-expand-lg navbar-light compensate-for-scrollbar" id="navbar-main">  <div class="container">    {{if $show_logo}}    <div class="d-none d-lg-inline-flex">      <a class="navbar-brand" href="{{ "/" | relLangURL }}">        {{- if site.Params.logo -}}          <img src="{{ printf "/img/%s" site.Params.logo | relURL }}" alt="{{ site.Title }}">        {{- else -}}          {{- site.Title -}}        {{- end -}}      </a>    </div>    {{end}}    {{ if site.Menus.main }}    <button type="button" class="navbar-toggler" data-toggle="collapse"            data-target="#navbar-content" aria-controls="navbar" aria-expanded="false" aria-label="{{ i18n "toggle_navigation" }}">    <span><i class="fas fa-bars"></i></span>    </button>    {{ end }}    {{if $show_logo}}    <div class="navbar-brand-mobile-wrapper d-inline-flex d-lg-none">      <a class="navbar-brand" href="{{ "/" | relLangURL }}">      {{- if site.Params.logo -}}      <img src="{{ printf "/img/%s" site.Params.logo | relURL }}" alt="{{ site.Title }}">      {{- else -}}      {{- site.Title -}}      {{- end -}}      </a>    </div>    {{end}}    <!-- Collect the nav links, forms, and other content for toggling -->    {{ $align_menu := site.Params.main_menu.align | default "l" }}    <div class="navbar-collapse main-menu-item collapse {{ if eq $align_menu "c" }}justify-content-center{{ else if eq $align_menu "r" }}justify-content-end{{else}}justify-content-start{{ end }}" id="navbar-content">      <!-- Left Nav Bar -->      <ul class="navbar-nav d-md-inline-flex">        {{ range site.Menus.main }}        {{ if .HasChildren }}        <li class="nav-item dropdown">          <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true">            {{- .Pre -}}<span>{{ .Name | safeHTML }}</span>{{- .Post -}}            <span class="caret"></span>          </a>          <div class="dropdown-menu">            {{ range .Children }}              <a class="dropdown-item" href="{{ .URL | relLangURL }}"{{ if $.IsHome }} data-target="{{ .URL }}"{{ end }}>                {{- .Pre -}}<span>{{ .Name | safeHTML }}</span>{{- .Post -}}              </a>            {{ end }}          </div>        </li>        {{ else }}        {{/* Set target for link. */}}        {{ $.Scratch.Set "target" "" }}        {{ if gt (len .URL) 4 }}          {{ if eq "http" (slicestr .URL 0 4) }}            {{ $.Scratch.Set "target" " target=\"_blank\" rel=\"noopener\"" }}          {{ end }}        {{ end }}        {{/* Get active page. */}}        {{ $is_link_in_current_path := in $current_page.RelPermalink .URL }}        {{ $is_widget_page := or $current_page.IsHome (eq $current_page.Type "widget_page") }}        {{ $hash := findRE "#(.+)" .URL }}        {{ $is_same_page := $is_link_in_current_path }}        {{ if gt (len $hash) 0 }}          {{ $hash = index $hash 0 }}          {{ $hash_removed := replace .URL $hash "" }}          {{ if eq (len $hash_removed) 0 }}            {{ $hash_removed = "/" }}{{/* Add robustness for `/#SECTION` or `#SECTION` in `menus.toml`. */}}          {{ end }}          {{ $is_same_page = eq (path.Dir $current_page.RelPermalink) (path.Dir ($hash_removed|relLangURL)) }}        {{ end }}        <li class="nav-item">          <a class="nav-link {{if $is_link_in_current_path }} active{{end}}" href="{{.URL | relLangURL}}"{{ if and $is_widget_page $is_same_page }} data-target="{{$hash}}"{{ end }}{{ ($.Scratch.Get "target") | safeHTMLAttr }}>            {{- .Pre -}}<span>{{ .Name | safeHTML }}</span>{{- .Post -}}          </a>        </li>        {{ end }}        {{ end }}      {{ if site.Menus.main_right | and (eq $align_menu "l") }}      </ul>      <ul class="navbar-nav ml-md-auto">      {{ end }}        {{ range site.Menus.main_right }}        {{/* Set target for link. */}}        {{ $.Scratch.Set "target" "" }}        {{ if gt (len .URL) 4 }}        {{ if eq "http" (slicestr .URL 0 4) }}        {{ $.Scratch.Set "target" " target=\"_blank\" rel=\"noopener\"" }}        {{ end }}        {{ end }}        <li class="nav-item">          <a class="nav-link" href="{{ .URL | relLangURL }}"{{ if $.IsHome }} data-target="{{ .URL }}"{{ end }}{{ ($.Scratch.Get "target") | safeHTMLAttr }}>            {{- .Pre -}}<span>{{ .Name | safeHTML }}</span>{{- .Post -}}          </a>        </li>        {{ end }}      </ul>    </div><!-- /.navbar-collapse -->    <ul class="nav-icons navbar-nav flex-row ml-auto d-flex pl-md-2">      {{ if site.Params.search.engine }}      <li class="nav-item">        <a class="nav-link js-search" href="#"><i class="fas fa-search" aria-hidden="true"></i></a>      </li>      {{ end }}      {{ if site.Params.day_night }}      <li class="nav-item">        <a class="nav-link js-dark-toggle" href="#"><i class="fas fa-moon" aria-hidden="true"></i></a>      </li>      {{ end }}      {{ if .IsTranslated }}      <li class="nav-item dropdown i18n-dropdown">        <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true">          <i class="fas fa-globe mr-1" aria-hidden="true"></i><span class="d-none d-lg-inline">{{ index site.Data.i18n.languages .Lang }}</span>        </a>        <div class="dropdown-menu">          <div class="dropdown-item i18n-active font-weight-bold">            <span>{{ index site.Data.i18n.languages .Lang }}</span>          </div>          {{ range .Translations }}          <a class="dropdown-item" href="{{ .RelPermalink }}"{{ if $.IsHome }} data-target="{{ .RelPermalink }}"{{ end }}>            <span>{{ index site.Data.i18n.languages .Lang }}</span>          </a>          {{ end }}        </div>      </li>      {{ end }}    </ul>  </div><!-- /.container --></nav>
 |