navbar.html 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. {{ $mainLogo:="/assets/images/main-logo.png" }}
  2. {{ $invertedLogo:="/assets/images/inverted-logo.png" }}
  3. {{ if site.Params.logo.main }}
  4. {{ $mainLogo = site.Params.logo.main }}
  5. {{ end }}
  6. {{ if site.Params.logo.inverted }}
  7. {{ $invertedLogo = site.Params.logo.inverted }}
  8. {{ end }}
  9. {{ $sections:= site.Data.sections }}
  10. {{ if (index site.Data site.Language.Lang).sections }}
  11. {{ $sections = (index site.Data site.Language.Lang).sections }}
  12. {{ end }}
  13. <nav class="navbar navbar-expand-xl top-navbar initial-navbar" id="top-navbar">
  14. <div class="container">
  15. <a class="navbar-brand" href="{{ site.BaseURL | relLangURL }}">
  16. <img src="{{ $invertedLogo | relURL }}" id="logo">
  17. {{- site.Title -}}
  18. </a>
  19. <button
  20. class="navbar-toggler navbar-dark"
  21. id="navbar-toggler"
  22. type="button"
  23. data-toggle="collapse"
  24. data-target="#top-nav-items"
  25. >
  26. <span class="navbar-toggler-icon"></span>
  27. </button>
  28. <div class="collapse navbar-collapse" id="top-nav-items">
  29. <ul class="navbar-nav ml-auto">
  30. <li class="nav-item">
  31. <a class="nav-link" href="#home">{{ i18n "home" }}</a>
  32. </li>
  33. {{ if $sections }}
  34. {{ range sort $sections "section.weight" }}
  35. {{ if and (.section.enable) (.section.showOnNavbar)}}
  36. {{ $sectionID := replace (lower .section.name) " " "-" }}
  37. {{ if .section.id }}
  38. {{ $sectionID = .section.id }}
  39. {{ end }}
  40. <li class="nav-item">
  41. <a class="nav-link" href="#{{ $sectionID }}">{{ .section.name }}</a>
  42. </li>
  43. {{ end }}
  44. {{- end }}
  45. {{- end }}
  46. {{ $hasCustomMenus:= false }}
  47. {{ if and site.Params.customMenus }}
  48. {{ if gt (len site.Params.customMenus) 0 }}
  49. {{ $hasCustomMenus = true }}
  50. {{ end }}
  51. {{ end }}
  52. {{ if (or site.Params.enableBlogPost $hasCustomMenus) }}
  53. <div class="dropdown-divider" id="top-navbar-divider"></div>
  54. {{ end }}
  55. {{ if site.Params.enableBlogPost }}
  56. <li class="nav-item">
  57. <a class="nav-link" id="blog-link" href="{{ "/posts" | relLangURL }}">{{ i18n "posts" }}</a>
  58. </li>
  59. {{ end }}
  60. {{ range (index site.Data site.Language.Lang).site.customMenus }}
  61. <li class="nav-item">
  62. <a class="nav-link" href="{{ .url }}">{{ .name }}</a>
  63. </li>
  64. {{ end }}
  65. {{ if .IsTranslated }}
  66. {{ partial "navigators/lang-selector.html" . }}
  67. {{ end }}
  68. </ul>
  69. </div>
  70. </div>
  71. <!-- Store the logo information in a hidden img for the JS -->
  72. <img src="{{ $mainLogo | relURL }}" class="d-none" id="main-logo">
  73. <img src="{{ $invertedLogo | relURL }}" class="d-none" id="inverted-logo">
  74. </nav>