Welcome to mirror list, hosted at ThFree Co, Russian Federation.

navbar.html « navigators « partials « layouts - github.com/hossainemruz/toha.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2daae09e32dc11b4b0958ea7554706fa7032487a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
{{/*  default logos  */}}
{{ $mainLogo := "/images/main-logo.png" }}
{{ $invertedLogo := "/images/inverted-logo.png" }}

{{/*  if custom logo is used, 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 */}}
{{ $mainLogo := resources.Get $mainLogo}}
{{ if and $mainLogo (ne $mainLogo.MediaType.SubType "svg") }}
  {{ $mainLogo = $mainLogo.Resize "42x" }}
{{ end }}
{{ $mainLogo = $mainLogo.RelPermalink}}

{{ $invertedLogo := resources.Get $invertedLogo}}
{{ if and $invertedLogo (ne $invertedLogo.MediaType.SubType "svg")}}
  {{ $invertedLogo = $invertedLogo.Resize "42x" }}
{{ end }}
{{ $invertedLogo = $invertedLogo.RelPermalink}}

{{ $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 }}">
      <img src="{{ $invertedLogo }}" id="logo" alt="Logo">
      {{- 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 }}
        {{ $hasCustomMenus:= false }}
        {{ if $customMenus }}
          {{ if gt (len $customMenus) 0 }}
            {{ $hasCustomMenus = true }}
          {{ end }}
        {{ end }}
        {{ if (or site.Params.enableBlogPost $hasCustomMenus) }}
          <div class="dropdown-divider" id="top-navbar-divider"></div>
        {{ end }}
        {{ if site.Params.enableBlogPost }}
          <li class="nav-item">
            <a class="nav-link" id="blog-link" href="{{ "/posts" | relLangURL }}">{{ i18n "posts" }}</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 -->
  <img src="{{ $mainLogo }}" class="d-none" id="main-logo" alt="Logo">
  <img src="{{ $invertedLogo }}" class="d-none" id="inverted-logo" alt="Inverted Logo">
</nav>