navbar-2.html 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. {{/* by default, don't use any logo */}}
  2. {{ $mainLogo := "" }}
  3. {{ $invertedLogo := "" }}
  4. {{/* if custom logo has been provided, use them */}}
  5. {{ if site.Params.logo.main }}
  6. {{ $mainLogo = site.Params.logo.main }}
  7. {{ end }}
  8. {{ if site.Params.logo.inverted }}
  9. {{ $invertedLogo = site.Params.logo.inverted }}
  10. {{ end }}
  11. {{/* resize the logos. don't resize svg because it is not supported */}}
  12. {{ if $mainLogo }}
  13. {{ $mainLogo = resources.Get $mainLogo}}
  14. {{ if and $mainLogo (ne $mainLogo.MediaType.SubType "svg") }}
  15. {{ $mainLogo = $mainLogo.Resize "42x" }}
  16. {{ end }}
  17. {{ $mainLogo = $mainLogo.RelPermalink}}
  18. {{ end }}
  19. {{ if $invertedLogo }}
  20. {{ $invertedLogo = resources.Get $invertedLogo}}
  21. {{ if and $invertedLogo (ne $invertedLogo.MediaType.SubType "svg")}}
  22. {{ $invertedLogo = $invertedLogo.Resize "42x" }}
  23. {{ end }}
  24. {{ $invertedLogo = $invertedLogo.RelPermalink}}
  25. {{ end }}
  26. <nav class="navbar navbar-expand-xl top-navbar final-navbar shadow">
  27. <div class="container">
  28. <button class="navbar-toggler navbar-light" id="sidebar-toggler" type="button">
  29. <span class="navbar-toggler-icon"></span>
  30. </button>
  31. <a class="navbar-brand" href="{{ site.BaseURL | relLangURL }}">
  32. {{ if $mainLogo }}
  33. <img src="{{ $mainLogo }}" alt="Logo">
  34. {{ end }}
  35. {{- site.Title -}}
  36. </a>
  37. <button class="navbar-toggler navbar-light" id="toc-toggler" type="button">
  38. <span class="navbar-toggler-icon"></span>
  39. </button>
  40. <div class="collapse navbar-collapse lang-selector" id="top-nav-items">
  41. <ul class="navbar-nav ml-auto">
  42. {{ if .IsTranslated }}
  43. {{ partial "navigators/lang-selector-2.html" . }}
  44. {{ end }}
  45. {{ if site.Params.features.darkMode.enable }}
  46. {{ partial "navigators/theme-selector.html" . }}
  47. {{ end }}
  48. </ul>
  49. </div>
  50. </div>
  51. <!-- Store the logo information in a hidden img for the JS -->
  52. {{ if $mainLogo }}
  53. <img src="{{ $mainLogo }}" class="d-none" id="main-logo" alt="Logo">
  54. {{ end }}
  55. {{ if $invertedLogo }}
  56. <img src="{{ $invertedLogo }}" class="d-none" id="inverted-logo" alt="Inverted Logo">
  57. {{ end }}
  58. </nav>