|
1 | 1 | {{- $textColor := cond .IsHome "text-white" "text-primary" -}} |
2 | 2 | {{- $borderColor := cond .IsHome "border-white" "border-primary" -}} |
| 3 | +{{- $hoverBorderColor := cond .IsHome "hover:border-white" "hover:border-primary" -}} |
3 | 4 | {{- $backgroundColor := cond .IsHome "bg-dark" "bg-white" -}} |
4 | 5 | {{- $currentRelPermalink := .RelPermalink -}} |
5 | 6 | <nav class="w-full max-h-screen {{ $textColor }} fixed {{ $backgroundColor }} shadow-sm z-50"> |
|
18 | 19 | </a> |
19 | 20 |
|
20 | 21 | <ul class="hidden lg:flex items-stretch list-none m-0"> |
21 | | - <li x-data="{ isProductsDropdownOpen: false }" class="flex items-center mx-2 border-b-2 border-transparent"> |
22 | | - <button @click="isProductsDropdownOpen = !isProductsDropdownOpen" class="whitespace-nowrap p-2"> |
23 | | - <span>{{ i18n "nav_products" . }}</span> |
| 22 | + {{- range .Site.Data.nav }} |
| 23 | + {{- if .Title }} |
| 24 | + <!-- Dropdown item --> |
| 25 | + <li x-data="{ isDropdownOpen: false, openedByHover: false }" class="flex items-center mx-2 border-b-2 border-transparent" @mouseenter="isDropdownOpen = true; openedByHover = true" @mouseleave="isDropdownOpen = false; openedByHover = false" @click.outside="isDropdownOpen = false"> |
| 26 | + <button @click="if (!openedByHover) { isDropdownOpen = !isDropdownOpen }" class="whitespace-nowrap p-2"> |
| 27 | + <span>{{ i18n .Title . }}</span> |
24 | 28 | <i class="fas fa-chevron-down fa-fw text-xs"></i> |
25 | 29 | </button> |
26 | 30 | <div class="absolute"> |
27 | | - <div x-show="isProductsDropdownOpen" @click.outside="isProductsDropdownOpen = false" x-cloak class="absolute mt-6 py-2 w-64 bg-white rounded-sm shadow-md z-50"> |
28 | | - {{- range .Site.Data.nav.ProductsRelLinks }} |
| 31 | + <ul x-show="isDropdownOpen" x-cloak class="absolute mt-6 py-2 whitespace-nowrap bg-white rounded-sm shadow-md z-50"> |
| 32 | + {{- range .Children }} |
| 33 | + {{- if eq . "|" }} |
| 34 | + <li> |
| 35 | + <hr class="border-gray-200 my-2"/> |
| 36 | + </li> |
| 37 | + {{- else }} |
29 | 38 | {{- with $.Site.GetPage . }} |
30 | | - <a href="{{ .RelPermalink }}" class="block px-4 py-2 text-gray-800 hover:bg-secondary hover:text-white hover:no-underline plausible-event-name=nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}" data-umami-event="nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}">{{ cond (isset .Params "navtitle") .Params.Navtitle .Title }}</a> |
31 | | - {{- end}} |
| 39 | + <li> |
| 40 | + <a href="{{ .RelPermalink }}" class="flex items-center px-4 py-2 text-gray-800 hover:bg-secondary hover:text-white hover:no-underline plausible-event-name=nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}" data-umami-event="nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}"> |
| 41 | + <span>{{ cond (isset .Params "navtitle") .Params.Navtitle .Title }}</span> |
| 42 | + {{- if .Params.Navbadge }} |
| 43 | + <span class="inline-flex px-2 py-1 rounded-full text-xs font-medium tracking-wide uppercase bg-primary-l2 text-dark ml-2">{{ .Params.Navbadge }}</span> |
| 44 | + {{- end }} |
| 45 | + </a> |
| 46 | + </li> |
32 | 47 | {{- end }} |
33 | | - </div> |
| 48 | + {{- end }} |
| 49 | + {{- end }} |
| 50 | + </ul> |
34 | 51 | </div> |
35 | 52 | </li> |
36 | | - {{- range .Site.Data.nav.RelLinks }} |
37 | | - {{- with $.Site.GetPage . }} |
| 53 | + {{- else if .URL }} |
| 54 | + <!-- Direct link --> |
| 55 | + {{- with $.Site.GetPage .URL }} |
38 | 56 | {{- $navItemBorderColor := cond (hasPrefix $currentRelPermalink .RelPermalink) $borderColor "border-transparent" }} |
39 | | - <li class="flex items-center mx-2 border-b-2 {{ $navItemBorderColor }} hover:{{ $borderColor }}"> |
40 | | - <a class="p-2 hover:no-underline plausible-event-name=nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}" href="{{ .RelPermalink }}" data-umami-event="nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}">{{ cond (isset .Params "navtitle") .Params.Navtitle .Title }}</a> |
| 57 | + <li class="flex items-center mx-2 border-b-2 {{ $navItemBorderColor }} {{ $hoverBorderColor }}"> |
| 58 | + <a class="p-2 hover:no-underline plausible-event-name=nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}" href="{{ .RelPermalink }}" data-umami-event="nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}"> |
| 59 | + {{ cond (isset .Params "navtitle") .Params.Navtitle .Title }} |
| 60 | + </a> |
41 | 61 | </li> |
42 | 62 | {{- end }} |
43 | 63 | {{- end }} |
44 | | - <li x-data="{ isSupportUsDropdownOpen: false }" class="flex items-center mx-2 border-b-2 border-transparent"> |
45 | | - <button @click="isSupportUsDropdownOpen = !isSupportUsDropdownOpen" class="whitespace-nowrap p-2"> |
46 | | - <span>{{ i18n "nav_support_us" . }}</span> |
47 | | - <i class="fas fa-chevron-down fa-fw text-xs"></i> |
48 | | - </button> |
49 | | - <div class="absolute"> |
50 | | - <div x-show="isSupportUsDropdownOpen" @click.outside="isSupportUsDropdownOpen = false" x-cloak class="absolute mt-6 py-2 w-64 bg-white rounded-sm shadow-md z-50"> |
51 | | - {{- range .Site.Data.nav.SupportUsRelLinks }} |
52 | | - {{- with $.Site.GetPage . }} |
53 | | - <a href="{{ .RelPermalink }}" class="block px-4 py-2 text-gray-800 hover:bg-secondary hover:text-white hover:no-underline plausible-event-name=nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}" data-umami-event="nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}">{{ cond (isset .Params "navtitle") .Params.Navtitle .Title }}</a> |
54 | | - {{- end}} |
55 | | - {{- end }} |
56 | | - </div> |
57 | | - </div> |
58 | | - </li> |
59 | | - <li x-data="{ isLearnMoreDropdownOpen: false }" class="flex items-center mx-2 border-b-2 border-transparent"> |
60 | | - <button @click="isLearnMoreDropdownOpen = !isLearnMoreDropdownOpen" class="whitespace-nowrap p-2"> |
61 | | - <span>{{ i18n "nav_learn_more" . }}</span> |
62 | | - <i class="fas fa-chevron-down fa-fw text-xs"></i> |
63 | | - </button> |
64 | | - <div class="absolute"> |
65 | | - <div x-show="isLearnMoreDropdownOpen" @click.outside="isLearnMoreDropdownOpen = false" x-cloak class="absolute mt-6 py-2 w-96 bg-white rounded-sm shadow-md z-50"> |
66 | | - {{- range .Site.Data.nav.LearnMoreRelLinks }} |
67 | | - {{- with $.Site.GetPage . }} |
68 | | - <a href="{{ .RelPermalink }}" class="block px-4 py-2 text-gray-800 hover:bg-secondary hover:text-white hover:no-underline plausible-event-name=nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}" data-umami-event="nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}">{{ cond (isset .Params "navtitle") .Params.Navtitle .Title }}</a> |
69 | | - {{- end}} |
70 | | - {{- end }} |
71 | | - </div> |
72 | | - </div> |
73 | | - </li> |
| 64 | + {{- end }} |
74 | 65 | </ul> |
75 | 66 | </div> |
76 | 67 |
|
|
94 | 85 |
|
95 | 86 | <ul class="hidden lg:flex items-stretch list-none m-0"> |
96 | 87 | <li class="flex items-center m-3 border-l {{ $borderColor }}"></li> |
97 | | - |
98 | | - <li x-data="{ isLangDropdownOpen: false }" class="flex items-center mx-2"> |
99 | | - <button @click="isLangDropdownOpen = !isLangDropdownOpen" class="whitespace-nowrap p-2"> |
| 88 | + <li x-data="{ isDropdownOpen: false, openedByHover: false }" class="flex items-center mx-2" @mouseenter="isDropdownOpen = true; openedByHover = true" @mouseleave="isDropdownOpen = false; openedByHover = false" @click.outside="isDropdownOpen = false"> |
| 89 | + <button @click="if (!openedByHover) { isDropdownOpen = !isDropdownOpen }" class="whitespace-nowrap p-2"> |
100 | 90 | <span>{{ .Site.Language.Lang | upper }}</span> |
101 | 91 | <i class="fas fa-chevron-down fa-fw text-xs"></i> |
102 | 92 | </button> |
103 | 93 | <div class="relative"> |
104 | | - <div x-show="isLangDropdownOpen" @click.outside="isLangDropdownOpen = false" x-cloak class="absolute right-0 mt-6 py-2 w-48 bg-white rounded-sm shadow-md z-50"> |
| 94 | + <ul x-show="isDropdownOpen" x-cloak class="absolute right-0 mt-6 py-2 w-48 bg-white rounded-sm shadow-md z-50"> |
105 | 95 | {{- range .Translations }} |
106 | | - <a :href="'{{ .RelPermalink }}' + (window.location.search ?? '')" lang="{{ .Lang }}" class="block px-4 py-2 text-gray-800 hover:bg-secondary hover:text-white hover:no-underline plausible-event-name=nav-lang-{{ .Lang }}" data-umami-event="nav-lang-{{ .Lang }}">{{ .Language.LanguageName }}</a> |
| 96 | + <li> |
| 97 | + <a :href="'{{ .RelPermalink }}' + (window.location.search ?? '')" lang="{{ .Lang }}" class="block px-4 py-2 text-gray-800 hover:bg-secondary hover:text-white hover:no-underline plausible-event-name=nav-lang-{{ .Lang }}" data-umami-event="nav-lang-{{ .Lang }}">{{ .Language.LanguageName }}</a> |
| 98 | + </li> |
107 | 99 | {{- end }} |
108 | | - </div> |
| 100 | + </ul> |
109 | 101 | </div> |
110 | 102 | </li> |
111 | 103 | </ul> |
|
114 | 106 |
|
115 | 107 | <!-- Smartphone Navigation --> |
116 | 108 | <div :class="isNavOpen ? 'block' : 'hidden'" x-cloak class="lg:hidden max-h-[calc(100vh-48px)] overflow-y-auto"> |
| 109 | + {{- range .Site.Data.nav }} |
| 110 | + {{- if .Title }} |
117 | 111 | <div class="uppercase tracking-wide text-gray-500 text-xs font-bold p-2"> |
118 | | - {{ i18n "nav_products" . }} |
| 112 | + {{ i18n .Title . }} |
119 | 113 | </div> |
120 | | - <div class="mt-1"> |
121 | | - {{- range .Site.Data.nav.ProductsRelLinks }} |
122 | | - {{- with $.Site.GetPage . }} |
123 | | - <a class="block py-2 mx-2 hover:text-secondary hover:no-underline plausible-event-name=nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}" href="{{ .RelPermalink }}" data-umami-event="nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}">{{ cond (isset .Params "navtitle") .Params.Navtitle .Title }}</a> |
124 | | - {{- end }} |
125 | | - {{- end }} |
126 | | - </div> |
127 | | - |
| 114 | + {{- range .Children }} |
| 115 | + {{- if eq . "|" }} |
128 | 116 | <hr class="border-primary my-2"/> |
129 | | - |
130 | | - {{- range .Site.Data.nav.RelLinks }} |
| 117 | + {{- else }} |
131 | 118 | {{- with $.Site.GetPage . }} |
132 | | - <a class="block py-2 mx-2 hover:text-secondary hover:no-underline plausible-event-name=nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}" href="{{ .RelPermalink }}" data-umami-event="nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}">{{ cond (isset .Params "navtitle") .Params.Navtitle .Title }}</a> |
| 119 | + <a class="block py-2 mx-2 hover:text-secondary hover:no-underline plausible-event-name=nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}" |
| 120 | + href="{{ .RelPermalink }}" data-umami-event="nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}"> |
| 121 | + <span>{{ cond (isset .Params "navtitle") .Params.Navtitle .Title }}</span> |
| 122 | + {{- if .Params.Navbadge }} |
| 123 | + <span class="inline-flex px-2 py-1 rounded-full text-xs font-medium tracking-wide uppercase bg-primary-l2 text-dark ml-2">{{ .Params.Navbadge }}</span> |
| 124 | + {{- end }} |
| 125 | + </a> |
| 126 | + {{- end }} |
133 | 127 | {{- end }} |
134 | 128 | {{- end }} |
135 | | - |
136 | 129 | <hr class="border-primary my-2"/> |
137 | | - |
138 | | - <div class="uppercase tracking-wide text-gray-500 text-xs font-bold p-2"> |
139 | | - {{ i18n "nav_support_us" . }} |
140 | | - </div> |
141 | | - <div class="mt-1"> |
142 | | - {{- range .Site.Data.nav.SupportUsRelLinks }} |
143 | | - {{- with $.Site.GetPage . }} |
144 | | - <a class="block py-2 mx-2 hover:text-secondary hover:no-underline plausible-event-name=nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}" href="{{ .RelPermalink }}" data-umami-event="nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}">{{ cond (isset .Params "navtitle") .Params.Navtitle .Title }}</a> |
145 | | - {{- end }} |
146 | | - {{- end }} |
147 | | - </div> |
148 | | - |
| 130 | + {{- else if .URL }} |
| 131 | + {{- with $.Site.GetPage .URL }} |
| 132 | + <a class="block py-2 mx-2 hover:text-secondary hover:no-underline plausible-event-name=nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}" |
| 133 | + href="{{ .RelPermalink }}" data-umami-event="nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}"> |
| 134 | + {{ cond (isset .Params "navtitle") .Params.Navtitle .Title }} |
| 135 | + </a> |
149 | 136 | <hr class="border-primary my-2"/> |
| 137 | + {{- end }} |
| 138 | + {{- end }} |
| 139 | + {{- end }} |
150 | 140 |
|
151 | | - <div class="uppercase tracking-wide text-gray-500 text-xs font-bold p-2"> |
152 | | - {{ i18n "nav_learn_more" . }} |
153 | | - </div> |
154 | | - <div class="mt-1"> |
155 | | - {{- range .Site.Data.nav.LearnMoreRelLinks }} |
156 | | - {{- with $.Site.GetPage . }} |
157 | | - <a class="block py-2 mx-2 hover:text-secondary hover:no-underline plausible-event-name=nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}" href="{{ .RelPermalink }}" data-umami-event="nav-{{ replaceRE "^.*/([^/]+)/?$" "$1" .RelPermalink }}">{{ cond (isset .Params "navtitle") .Params.Navtitle .Title }}</a> |
158 | | - {{- end }} |
159 | | - {{- end }} |
160 | | - </div> |
161 | | - |
162 | | - <hr class="border-primary my-2"/> |
163 | | - |
164 | 141 | <div class="uppercase tracking-wide text-gray-500 text-xs font-bold p-2"> |
165 | 142 | <i class="fas fa-globe fa-fw"></i> {{ .Site.Language.Lang | upper }} |
166 | 143 | </div> |
|
0 commit comments