nav.html 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <nav class="navbar navbar-expand-lg navbar-light bg-light px-3">
  2. <div class="container-fluid flex-nowrap">
  3. <a class="navbar-brand" href="/">
  4. <img src="/img/logo/logo(橫).png" alt="" class="logo">
  5. </a>
  6. <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent"
  7. aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  8. <span class="navbar-toggler-icon"></span>
  9. </button>
  10. <div class="collapse navbar-collapse" id="navbarSupportedContent">
  11. <ul class="navbar-nav me-auto mb-2 mb-lg-0 mt-4 mt-lg-0">
  12. {{ $currentPage := . }}
  13. {{ range .Site.Menus.main }}
  14. {{ if .HasChildren }}
  15. <li class="nav-item dropdown">
  16. <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown"
  17. aria-expanded="false">
  18. {{ .Pre }}
  19. <span>{{ .Name }}</span>
  20. </a>
  21. <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
  22. {{ range .Children }}
  23. <li class="{{ if $currentPage.IsMenuCurrent " main" . }}active{{ end }}">
  24. <a class="dropdown-item" href="{{ .URL }}">{{ .Name }}</a>
  25. </li>
  26. {{ end }}
  27. </ul>
  28. </li>
  29. {{ else }}
  30. <li class="nav-item">
  31. <a class="nav-link" href="{{ .URL }}">
  32. {{ .Pre }}
  33. <span>{{ .Name }}</span>
  34. </a>
  35. </li>
  36. {{ end }}
  37. {{ end }}
  38. </ul>
  39. </div>
  40. </div>
  41. </nav>