208 lines
7.3 KiB
HTML
208 lines
7.3 KiB
HTML
{{/* Logo section */}}
|
|
{{ define "HeaderLogo" }}
|
|
{{ if .Site.Params.Logo }}
|
|
{{ $logo := resources.Get .Site.Params.Logo }}
|
|
{{ if $logo }}
|
|
<div>
|
|
<a href="{{ "" | relLangURL }}" class="flex">
|
|
<span class="sr-only">{{ .Site.Title | markdownify }}</span>
|
|
{{ if eq $logo.MediaType.SubType "svg" }}
|
|
<span class="logo object-scale-down object-left nozoom">
|
|
{{ $logo.Content | safeHTML }}
|
|
</span>
|
|
{{ else }}
|
|
<img
|
|
src="{{ $logo.RelPermalink }}"
|
|
width="{{ div $logo.Width 2 }}"
|
|
height="{{ div $logo.Height 2 }}"
|
|
class="logo max-h-[5rem] max-w-[5rem] object-scale-down object-left nozoom"
|
|
alt="{{ .Site.Title }}">
|
|
{{ end }}
|
|
</a>
|
|
</div>
|
|
{{ end }}
|
|
{{- end }}
|
|
{{ end }}
|
|
|
|
{{/* Desktop navigation */}}
|
|
{{ define "HeaderDesktopNavigation" }}
|
|
<nav class="hidden md:flex items-center gap-x-5 md:ml-12 h-12">
|
|
{{ if .Site.Menus.main }}
|
|
{{ range .Site.Menus.main }}
|
|
{{ partial "header/header-option.html" . }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{ partial "translations.html" . }}
|
|
|
|
{{ if .Site.Params.enableSearch | default false }}
|
|
<button
|
|
id="search-button"
|
|
aria-label="Search"
|
|
class="text-base hover:text-primary-600 dark:hover:text-primary-400"
|
|
title="{{ i18n "search.open_button_title" }}">
|
|
{{ partial "icon.html" "search" }}
|
|
</button>
|
|
{{ end }}
|
|
|
|
{{ if .Site.Params.footer.showAppearanceSwitcher | default false }}
|
|
<div class="{{ if .Site.Params.footer.showScrollToTop | default true -}}{{- end }} flex items-center">
|
|
<button
|
|
id="appearance-switcher"
|
|
aria-label="Dark mode switcher"
|
|
type="button"
|
|
class="text-base hover:text-primary-600 dark:hover:text-primary-400">
|
|
<div class="flex items-center justify-center dark:hidden">
|
|
{{ partial "icon.html" "moon" }}
|
|
</div>
|
|
<div class="items-center justify-center hidden dark:flex">
|
|
{{ partial "icon.html" "sun" }}
|
|
</div>
|
|
</button>
|
|
</div>
|
|
{{ end }}
|
|
</nav>
|
|
{{ end }}
|
|
|
|
{{/* Mobile navigation */}}
|
|
{{ define "HeaderMobileNavigation" }}
|
|
<div class="flex md:hidden items-center gap-x-5 md:ml-12 h-12">
|
|
<span></span>
|
|
|
|
{{ partial "translations.html" . }}
|
|
{{ if .Site.Params.enableSearch | default false }}
|
|
<button
|
|
id="search-button-mobile"
|
|
aria-label="Search"
|
|
class="text-base hover:text-primary-600 dark:hover:text-primary-400"
|
|
title="{{ i18n "search.open_button_title" }}">
|
|
{{ partial "icon.html" "search" }}
|
|
</button>
|
|
{{ end }}
|
|
|
|
{{ if .Site.Params.footer.showAppearanceSwitcher | default false }}
|
|
<button
|
|
id="appearance-switcher-mobile"
|
|
aria-label="Dark mode switcher"
|
|
type="button"
|
|
class="text-base hover:text-primary-600 dark:hover:text-primary-400 ltr:mr-1 rtl:ml-1">
|
|
<div class="flex items-center justify-center dark:hidden">
|
|
{{ partial "icon.html" "moon" }}
|
|
</div>
|
|
<div class="items-center justify-center hidden dark:flex">
|
|
{{ partial "icon.html" "sun" }}
|
|
</div>
|
|
</button>
|
|
{{ end }}
|
|
</div>
|
|
{{ end }}
|
|
|
|
{{ define "HeaderMobileMenu" }}
|
|
<div class="-my-2 md:hidden">
|
|
<div id="menu-button" class="block">
|
|
{{ if .Site.Menus.main }}
|
|
<div class="cursor-pointer hover:text-primary-600 dark:hover:text-primary-400">
|
|
{{ partial "icon.html" "bars" }}
|
|
</div>
|
|
<div
|
|
id="menu-wrapper"
|
|
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]">
|
|
<ul
|
|
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">
|
|
<li id="menu-close-button">
|
|
<span
|
|
class="cursor-pointer inline-block align-text-bottom hover:text-primary-600 dark:hover:text-primary-400">
|
|
{{ partial "icon.html" "xmark" }}
|
|
</span>
|
|
</li>
|
|
|
|
{{ range .Site.Menus.main }}
|
|
{{ partial "header/header-mobile-option.html" . }}
|
|
{{ end }}
|
|
|
|
</ul>
|
|
{{ if .Site.Menus.subnavigation }}
|
|
<hr>
|
|
<ul
|
|
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">
|
|
{{ range .Site.Menus.subnavigation }}
|
|
<li class="mb-1">
|
|
<a
|
|
href="{{ .URL }}"
|
|
{{ if or (strings.HasPrefix .URL "http:" ) (strings.HasPrefix .URL "https:") }}
|
|
target="_blank"
|
|
{{ end }}
|
|
class="flex items-center">
|
|
{{ if .Pre }}
|
|
<span {{ if and .Pre .Name }}class="mr-3"{{ end }}>
|
|
{{ partial "icon.html" .Pre }}
|
|
</span>
|
|
{{ end }}
|
|
<p class="text-sm font-sm text-gray-500 hover:text-gray-900" title="{{ .Title }}">
|
|
{{ .Name | markdownify }}
|
|
</p>
|
|
</a>
|
|
</li>
|
|
{{ end }}
|
|
</ul>
|
|
{{ end }}
|
|
</div>
|
|
{{ end }}
|
|
</div>
|
|
</div>
|
|
{{ end }}
|
|
|
|
{{/* ========== Render HTML ========== */}}
|
|
<div
|
|
class="main-menu flex items-center justify-between px-4 py-6 sm:px-6 md:justify-start gap-x-3 pt-[2px] pr-0 pb-[3px] pl-0">
|
|
{{ template "HeaderLogo" . }}
|
|
<div class="flex flex-1 items-center justify-between">
|
|
<nav class="flex space-x-3">
|
|
{{ if not .Site.Params.disableTextInHeader | default true }}
|
|
<a href="{{ "" | relLangURL }}" class="text-base font-medium text-gray-500 hover:text-gray-900">
|
|
{{ .Site.Title | markdownify }}
|
|
</a>
|
|
{{ end }}
|
|
</nav>
|
|
{{ template "HeaderDesktopNavigation" . }}
|
|
{{ template "HeaderMobileNavigation" . }}
|
|
</div>
|
|
{{ template "HeaderMobileMenu" . }}
|
|
</div>
|
|
|
|
{{ if .Site.Menus.subnavigation }}
|
|
<div
|
|
class="main-menu flex pb-3 flex-col items-end justify-between md:justify-start space-x-3{{ if .Site.Params.Logo }} -mt-[15px]{{ end }}">
|
|
<div class="hidden md:flex items-center space-x-5">
|
|
{{ range .Site.Menus.subnavigation }}
|
|
<a
|
|
href="{{ .URL }}"
|
|
{{ if or (strings.HasPrefix .URL "http:" ) (strings.HasPrefix .URL "https:" ) }}
|
|
target="_blank"
|
|
{{ end }}
|
|
class="flex items-center">
|
|
{{ if .Pre }}
|
|
<span {{ if and .Pre .Name }}class="mr-1"{{ end }}>
|
|
{{ partial "icon.html" .Pre }}
|
|
</span>
|
|
{{ end }}
|
|
<p class="text-xs font-light text-gray-500 hover:text-gray-900" title="{{ .Title }}">
|
|
{{ .Name | markdownify }}
|
|
</p>
|
|
</a>
|
|
{{ end }}
|
|
</div>
|
|
</div>
|
|
{{ end }}
|
|
|
|
{{ if .Site.Params.highlightCurrentMenuArea }}
|
|
<script>
|
|
(function () {
|
|
var $mainmenu = $(".main-menu");
|
|
var path = window.location.pathname;
|
|
$mainmenu.find('a[href="' + path + '"]').each(function (i, e) {
|
|
$(e).children("p").addClass("active");
|
|
});
|
|
})();
|
|
</script>
|
|
{{ end }}
|