nav.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <!-- Google Tag Manager (noscript) -->
  2. <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-TTKNPPT" height="0" width="0"
  3. style="display:none;visibility:hidden"></iframe></noscript>
  4. <!-- End Google Tag Manager (noscript) -->
  5. <header>
  6. <nav class="navbar navbar-expand-lg navbar-dark p-0">
  7. <div class="container-fluid p-0">
  8. <div class="mx-auto">
  9. <a class="navbar-brand home" href="/">
  10. {{ if default false .Site.Params.disabled_logo }}
  11. <h4>{{ .Site.Params.logo_text }}</h4>
  12. {{ else }}
  13. <img src="{{ .Site.Params.logo_mobile | relURL }}" alt="{{ .Title }} logo" height="60px" width="160px"
  14. alt="" />
  15. {{ end }}
  16. <span class="sr-only">{{ .Title }} - {{ i18n "navHome" }}</span>
  17. </a>
  18. </div>
  19. <button onclick="changeIcon(this)" class="navbar-toggler" type="button" data-bs-toggle="collapse"
  20. data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false"
  21. aria-label="Toggle navigation">
  22. <span data-toggle-class="icon" class="navbar-toggler-icon"></span>
  23. </button>
  24. <div class="collapse navbar-collapse" id="navbarSupportedContent">
  25. <ul class="navbar-nav align-items-lg-center mx-auto mb-2 mb-lg-0">
  26. <li class="navbar-logo">
  27. <a href="/">
  28. {{ if default false .Site.Params.disabled_logo }}
  29. <h4>{{ .Site.Params.logo_text }}</h4>
  30. {{ else }}
  31. <img src="{{ .Site.Params.logo | relURL }}" alt="{{ .Title }} logo" height="50px" alt=""
  32. style="image-rendering: -webkit-optimize-contrast;" />
  33. {{ end }}
  34. <span class="sr-only">{{ .Title }} - {{ i18n "navHome" }}</span>
  35. </a>
  36. </li>
  37. {{ $current := . }}
  38. {{ range .Site.Menus.main.ByWeight }}
  39. {{ $topLevel := replace .URL "/" "" }}
  40. {{ $active := "" }}
  41. {{ if eq $current.RelPermalink .URL }}
  42. {{ $active = "active" }}
  43. {{ end }}
  44. {{ if eq $current.Type $topLevel }}
  45. {{ $active = "active" }}
  46. {{ end }}
  47. {{ if and (or (eq $current.RelPermalink .URL) (eq "term" $current.Kind)) (in (slice "page" "term")
  48. $current.Kind) }}
  49. {{ range (split .URL "/") }}
  50. {{ if eq "blog" . }}
  51. {{ $active = "active" }}
  52. {{ end }}
  53. {{ end }}
  54. {{ end }}
  55. <li class="nav-item {{ $active }}">
  56. <a class="navbar-link" href="{{ .URL }}">{{ .Name }}</a>
  57. </li>
  58. {{ end }}
  59. <!-- <li class="">
  60. <a class="navbar-link" href="/collection.html">室內設計作品</a>
  61. </li>
  62. <li class="nav-item">
  63. <a class="navbar-link" href="/room_planner.html">成家設計服務</a>
  64. </li>
  65. <li class="nav-item">
  66. <a class="navbar-link" href="/frequently_asked_questions.html">服務常見QA</a>
  67. </li>
  68. <li class="nav-item">
  69. <a class="navbar-link" href="/categories.html">成家知識專欄</a>
  70. </li>
  71. <li class="nav-item">
  72. <a class="navbar-link" href="/furniture_design.html">小寶設計單品</a>
  73. </li>
  74. <li class="nav-item">
  75. <a class="navbar-link" href="/store.html">小寶優居門市</a>
  76. </li> -->
  77. </ul>
  78. </div>
  79. </div>
  80. </nav>
  81. </header>
  82. <script>
  83. // Navbar Icon
  84. function changeIcon(e) {
  85. const item = document.querySelector('[data-toggle-class]');
  86. item.className === "close-btn" ? item.className = "navbar-toggler-icon" : item.className = "close-btn";
  87. }
  88. let storeLink = document.querySelector('.navbar-nav li:last-child');
  89. storeLink.addEventListener('click', function () {
  90. localStorage.setItem('store', 'scope');
  91. })
  92. </script>
  93. <!-- *** NAVBAR END ***-->