navbar.html 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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
  32. class="nav-link"
  33. href="#home"
  34. data-toggle="collapse"
  35. data-target=".navbar-collapse"
  36. aria-controls="collapseExample"
  37. role="button"
  38. >
  39. {{ i18n "home" }}
  40. </a>
  41. </li>
  42. {{ if $sections }}
  43. {{ range sort $sections "section.weight" }}
  44. {{ if and (.section.enable) (.section.showOnNavbar)}}
  45. {{ $sectionID := replace (lower .section.name) " " "-" }}
  46. {{ if .section.id }}
  47. {{ $sectionID = .section.id }}
  48. {{ end }}
  49. <li class="nav-item">
  50. <a
  51. class="nav-link"
  52. href="#{{ $sectionID }}"
  53. data-toggle="collapse"
  54. data-target=".navbar-collapse"
  55. aria-controls="collapseExample"
  56. >
  57. {{ .section.name }}
  58. </a>
  59. </li>
  60. {{ end }}
  61. {{- end }}
  62. {{- end }}
  63. {{ $hasCustomMenus:= false }}
  64. {{ if and site.Params.customMenus }}
  65. {{ if gt (len site.Params.customMenus) 0 }}
  66. {{ $hasCustomMenus = true }}
  67. {{ end }}
  68. {{ end }}
  69. {{ if (or site.Params.enableBlogPost $hasCustomMenus) }}
  70. <div class="dropdown-divider" id="top-navbar-divider"></div>
  71. {{ end }}
  72. {{ if site.Params.enableBlogPost }}
  73. <li class="nav-item">
  74. <a class="nav-link" id="blog-link" href="{{ "/posts" | relLangURL }}">{{ i18n "posts" }}</a>
  75. </li>
  76. {{ end }}
  77. {{ range (index site.Data site.Language.Lang).site.customMenus }}
  78. <li class="nav-item">
  79. <a class="nav-link" href="{{ .url }}">{{ .name }}</a>
  80. </li>
  81. {{ end }}
  82. {{ if .IsTranslated }}
  83. {{ partial "navigators/lang-selector.html" . }}
  84. {{ end }}
  85. </ul>
  86. </div>
  87. </div>
  88. <!-- Store the logo information in a hidden img for the JS -->
  89. <img src="{{ $mainLogo | relURL }}" class="d-none" id="main-logo">
  90. <img src="{{ $invertedLogo | relURL }}" class="d-none" id="inverted-logo">
  91. </nav>