|
3 | 3 | {{ if .Site.Params.Logo }} |
4 | 4 | {{ $logo := resources.Get .Site.Params.Logo }} |
5 | 5 | {{ if $logo }} |
| 6 | + {{ $scalingFactor := 0.125 }} |
6 | 7 | <div> |
7 | 8 | <a href="{{ "" | relLangURL }}" class="flex"> |
8 | 9 | <span class="sr-only">{{ .Site.Title | markdownify }}</span> |
|
13 | 14 | {{ else }} |
14 | 15 | <img |
15 | 16 | src="{{ $logo.RelPermalink }}" |
16 | | - width="{{ div $logo.Width 2 }}" |
17 | | - height="{{ div $logo.Height 2 }}" |
18 | | - class="logo max-h-[5rem] max-w-[5rem] object-scale-down object-left nozoom" |
19 | | - alt=""> |
| 17 | + width="{{ mul $logo.Width $scalingFactor }}" |
| 18 | + height="{{ mul $logo.Height $scalingFactor }}" |
| 19 | + class="logo max-h-{{ printf "[%grem]" (mul 5 $scalingFactor) }} max-w-{{ printf "[%grem]" (mul 5 $scalingFactor) }} object-scale-down object-left nozoom" |
| 20 | + alt=""> |
20 | 21 | {{ end }} |
21 | 22 | </a> |
22 | 23 | </div> |
|
49 | 50 | {{ end }} |
50 | 51 |
|
51 | 52 | {{ if .Site.Params.footer.showAppearanceSwitcher | default false }} |
52 | | - <div class="{{ if .Site.Params.footer.showScrollToTop | default true -}}{{- end }} flex items-center"> |
| 53 | + <div class="{{ if .Site.Params.footer.showScrollToTop | default true -}} ltr:mr-14 rtl:ml-14 {{- end }} cursor-pointer text-sm text-neutral-700 hover:text-primary-600 dark:text-neutral dark:hover:text-primary-400"> |
53 | 54 | <button |
54 | 55 | id="appearance-switcher" |
55 | 56 | aria-label="Dark mode switcher" |
|
69 | 70 |
|
70 | 71 | {{/* Mobile navigation */}} |
71 | 72 | {{ define "HeaderMobileToolbar" }} |
72 | | - <div class="flex md:hidden items-center gap-x-5 md:ml-12 h-12"> |
73 | | - <span></span> |
74 | | - |
75 | 73 | {{ partial "translations.html" . }} |
76 | 74 | {{ if .Site.Params.enableA11y | default false }} |
77 | 75 | {{ template "HeaderA11y" (dict "prefix" "mobile-" "Site" .Site) }} |
|
101 | 99 | </div> |
102 | 100 | </button> |
103 | 101 | {{ end }} |
104 | | - </div> |
105 | 102 | {{ end }} |
106 | 103 |
|
107 | 104 | {{ define "HeaderMobileNavigation" }} |
108 | | - <div class="-my-2 md:hidden"> |
109 | 105 | <div id="menu-button" class="block"> |
110 | 106 | {{ if .Site.Menus.main }} |
111 | 107 | <div class="cursor-pointer hover:text-primary-600 dark:hover:text-primary-400"> |
112 | 108 | {{ partial "icon.html" "bars" }} |
113 | 109 | </div> |
114 | 110 | <div |
115 | 111 | id="menu-wrapper" |
116 | | - class="fixed inset-0 z-30 invisible w-screen h-screen m-0 overflow-auto transition-opacity opacity-0 cursor-default bg-neutral-100/50 backdrop-blur-sm dark:bg-neutral-900/50 pt-[5px]"> |
| 112 | + class="fixed inset-0 z-30 invisible w-screen h-screen m-0 overflow-auto transition-opacity opacity-0 cursor-default bg-neutral-100/50 backdrop-blur-sm dark:bg-neutral-900/50"> |
117 | 113 | <ul |
118 | | - class="flex space-y-2 mt-3 flex-col items-end w-full px-6 py-6 mx-auto overflow-visible list-none text-end max-w-7xl"> |
| 114 | + class="flex space-y-2 mt-3 flex-col items-end w-full px-6 py-6 mx-auto overflow-visible list-none ltr:text-right rtl:text-left max-w-7xl menu-ul"> |
119 | 115 | <li id="menu-close-button"> |
120 | 116 | <span |
121 | | - class="cursor-pointer inline-block align-text-bottom hover:text-primary-600 dark:hover:text-primary-400"> |
| 117 | + class="cursor-pointer inline-block align-text-bottom hover:text-primary-600 dark:hover:text-primary-400 menu-close"> |
122 | 118 | {{ partial "icon.html" "xmark" }} |
123 | 119 | </span> |
124 | 120 | </li> |
|
131 | 127 | {{ if .Site.Menus.subnavigation }} |
132 | 128 | <hr> |
133 | 129 | <ul |
134 | | - class="flex mt-4 flex-col items-end w-full px-6 py-6 mx-auto overflow-visible list-none text-end max-w-7xl"> |
| 130 | + class="flex mt-4 flex-col items-end w-full px-6 py-6 mx-auto overflow-visible list-none ltr:text-right rtl:text-left max-w-7xl"> |
135 | 131 | {{ range .Site.Menus.subnavigation }} |
136 | 132 | <li class="mb-1"> |
137 | 133 | <a |
|
142 | 138 | class="flex items-center"> |
143 | 139 | {{ if .Pre }} |
144 | 140 | <span {{ if and .Pre .Name }}class="mr-3"{{ end }}> |
145 | | - {{ partial "icon.html" .Pre }} |
| 141 | + {{ partial "icon.html" .Pre }} |
146 | 142 | </span> |
147 | 143 | {{ end }} |
148 | | - <p class="text-sm font-sm" title="{{ .Title }}"> |
149 | | - {{ .Name | markdownify }} |
| 144 | + <p class="text-sm font-sm text-gray-500 hover:text-gray-900" title="{{ .Title }}"> |
| 145 | + {{ .Name | markdownify | emojify }} |
150 | 146 | </p> |
151 | 147 | </a> |
152 | 148 | </li> |
|
156 | 152 | </div> |
157 | 153 | {{ end }} |
158 | 154 | </div> |
159 | | - </div> |
160 | 155 | {{ end }} |
161 | 156 |
|
162 | 157 | {{ define "HeaderA11y" }} |
|
200 | 195 | <div class="space-y-5"> |
201 | 196 | {{ $toggles := slice }} |
202 | 197 | {{ $shouldDisableBlur := or site.Params.homepage.layoutBackgroundBlur site.Params.article.layoutBackgroundBlur site.Params.list.layoutBackgroundBlur }} |
203 | | - {{ $shouldDisableBackgroundImage := or |
| 198 | + {{ $shouldDisableBackgroundImage := or |
204 | 199 | (eq site.Params.homepage.layout "background") |
205 | 200 | (eq site.Params.article.heroStyle "background") |
206 | 201 | (eq site.Params.list.heroStyle "background") |
|
252 | 247 |
|
253 | 248 | {{/* ========== Render HTML ========== */}} |
254 | 249 | <div |
255 | | - class="main-menu flex items-center justify-between py-6 md:justify-start gap-x-3 pt-[2px] pr-2 md:pr-4 pb-[3px] pl-0"> |
| 250 | + style="padding-left:0;padding-right:0;padding-top:2px;padding-bottom:3px" |
| 251 | + class="main-menu flex flex-wrap items-center justify-between px-4 py-6 sm:px-6 md:justify-start gap-x-3"> |
256 | 252 | {{ template "HeaderLogo" . }} |
257 | | - <div class="flex flex-1 items-center justify-between"> |
| 253 | + |
| 254 | + <div class="flex flex-1 items-center justify-between w-full md:w-auto"> |
258 | 255 | <nav class="flex space-x-3"> |
259 | 256 | {{ if not .Site.Params.disableTextInHeader | default true }} |
260 | | - <a href="{{ "" | relLangURL }}" class="text-base font-medium"> |
261 | | - {{ .Site.Title | markdownify }} |
| 257 | + <a href="{{ "" | relLangURL }}" class="text-base font-medium text-gray-500 hover:text-gray-900"> |
| 258 | + {{ .Site.Title | markdownify | emojify }} |
262 | 259 | </a> |
263 | 260 | {{ end }} |
264 | 261 | </nav> |
265 | 262 | {{ template "HeaderDesktopNavigation" . }} |
266 | | - {{ template "HeaderMobileToolbar" . }} |
267 | 263 | </div> |
268 | | - {{ template "HeaderMobileNavigation" . }} |
| 264 | + <div class="w-full flex flex-wrap justify-end items-center gap-x-5 md:hidden mt-2"> |
| 265 | + {{ template "HeaderMobileToolbar" . }} |
| 266 | + {{ template "HeaderMobileNavigation" . }} |
| 267 | + </div> |
269 | 268 | </div> |
270 | 269 |
|
271 | 270 | {{ if .Site.Menus.subnavigation }} |
272 | 271 | <div |
273 | | - class="main-menu flex pb-3 flex-col items-end justify-between md:justify-start space-x-3 {{ if .Site.Params.Logo }} |
274 | | - -mt-[15px] |
275 | | - {{ end }}"> |
| 272 | + class="main-menu flex pb-3 flex-col items-end justify-between md:justify-start space-x-3" {{ if .Site.Params.Logo }} |
| 273 | + style="margin-top:-15px" |
| 274 | + {{ end }}> |
276 | 275 | <div class="hidden md:flex items-center space-x-5"> |
277 | 276 | {{ range .Site.Menus.subnavigation }} |
278 | 277 | <a |
|
286 | 285 | {{ partial "icon.html" .Pre }} |
287 | 286 | </span> |
288 | 287 | {{ end }} |
289 | | - <p class="text-xs font-light" title="{{ .Title }}"> |
290 | | - {{ .Name | markdownify }} |
| 288 | + <p class="text-xs font-light text-gray-500 hover:text-gray-900" title="{{ .Title }}"> |
| 289 | + {{ .Name | markdownify | emojify }} |
291 | 290 | </p> |
292 | 291 | </a> |
293 | 292 | {{ end }} |
|
298 | 297 | {{ if .Site.Params.highlightCurrentMenuArea }} |
299 | 298 | <script> |
300 | 299 | (function () { |
301 | | - var $mainmenu = $(".main-menu"); |
302 | | - var path = window.location.pathname; |
303 | | - $mainmenu.find('a[href="' + path + '"]').each(function (i, e) { |
304 | | - $(e).children("p").addClass("active"); |
305 | | - }); |
| 300 | + var $mainmenu = $(".main-menu"); |
| 301 | + var path = window.location.pathname; |
| 302 | + $mainmenu.find('a[href="' + path + '"]').each(function (i, e) { |
| 303 | + $(e).children("p").addClass("active"); |
| 304 | + }); |
| 305 | + // Add the click event of the first level menu to realize the expansion and collapse of the menu |
| 306 | + document.querySelectorAll('#menu-wrapper .mt-1').forEach((parent) => { |
| 307 | + parent.style.width = '7rem'; |
| 308 | + parent.style.textAlign = 'left'; |
| 309 | + if (parent.querySelector('span') !== null) { |
| 310 | + parent.addEventListener("click", function (e) { |
| 311 | + e.preventDefault(); |
| 312 | + e.stopPropagation(); |
| 313 | + const root = document.querySelector('#menu-wrapper'); |
| 314 | + root.style.display = 'block'; |
| 315 | + if (this.classList.contains('menu-show')) { |
| 316 | + this.classList.remove('menu-show'); |
| 317 | + } else { |
| 318 | + this.classList.add('menu-show'); |
| 319 | + } |
| 320 | + // Find the second-level menu li corresponding to the first-level menu and display or hide it according to the style |
| 321 | + var nextLiElements = []; |
| 322 | + var nextSibling = this.nextSibling; |
| 323 | + while (nextSibling) { |
| 324 | + if (nextSibling.nodeType === 1 && nextSibling.classList.contains('mb-2')) { |
| 325 | + break; |
| 326 | + } |
| 327 | + if (nextSibling.nodeType === 1 && nextSibling.tagName.toLowerCase() === 'li') { |
| 328 | + nextLiElements.push(nextSibling); |
| 329 | + } |
| 330 | + nextSibling = nextSibling.nextSibling; |
| 331 | + } |
| 332 | + |
| 333 | + nextLiElements.forEach(function(nextLi) { |
| 334 | + nextLi.style.display = parent.classList.contains('menu-show') ? 'block' : 'none' |
| 335 | + }); |
| 336 | + }) |
| 337 | + } |
| 338 | + if (parent.querySelector('a')?.querySelector('p.text-sm')) { |
| 339 | + parent.style.display = 'none'; |
| 340 | + } |
| 341 | + }); |
| 342 | + document.querySelectorAll('#menu-wrapper .mb-2').forEach((node) => { |
| 343 | + node.style.display = 'none'; |
| 344 | + }); |
306 | 345 | })(); |
307 | 346 | </script> |
308 | 347 | {{ end }} |
| 348 | + |
| 349 | +{{ $styles := resources.Get "css/styles.css" }} |
| 350 | +{{ if $styles }} |
| 351 | + <link rel="stylesheet" href="{{ $styles.Permalink }}" integrity="{{ $styles.Data.Integrity }}"> |
| 352 | +{{ end }} |
0 commit comments