lpk-website

Lillehammer pistolklubb website
git clone https://git.echoz.io/lpk-website.git
Log | Files | Refs | README | LICENSE

header.html (6680B)


      1 <header class="header">
      2     <nav class="header-nav">
      3         <div class="logo">
      4             {{- $label_text := (site.Params.label.text | default site.Title) }}
      5             {{- if site.Title }}
      6             <a href="{{ "" | absLangURL }}" accesskey="h" title="{{ $label_text }} (Alt + H)">
      7                 {{- if site.Params.label.icon }}
      8                 {{- $img := resources.Get site.Params.label.icon }}
      9                 {{- if $img }}
     10                     {{- $processableFormats := (slice "jpg" "jpeg" "png" "tif" "bmp" "gif") -}}
     11                     {{- if hugo.IsExtended -}}
     12                         {{- $processableFormats = $processableFormats | append "webp" -}}
     13                     {{- end -}}
     14                     {{- $prod := (hugo.IsProduction | or (eq site.Params.env "production")) }}
     15                     {{- if and (in $processableFormats $img.MediaType.SubType) (eq $prod true)}}
     16                         {{- if site.Params.label.iconHeight }}
     17                             {{- $img = $img.Resize (printf "x%d" site.Params.label.iconHeight) }}
     18                         {{ else }}
     19                             {{- $img = $img.Resize "x30" }}
     20                         {{- end }}
     21                     {{- end }}
     22                     <img src="{{ $img.Permalink }}" alt="" aria-label="logo"
     23                         height="{{- site.Params.label.iconHeight | default "30" -}}">
     24                 {{- else }}
     25                 <img src="{{- site.Params.label.icon | absURL -}}" alt="" aria-label="logo"
     26                     height="{{- site.Params.label.iconHeight | default "30" -}}">
     27                 {{- end -}}
     28                 {{- else if hasPrefix site.Params.label.iconSVG "<svg" }}
     29                     {{ site.Params.label.iconSVG | safeHTML }}
     30                 {{- end -}}
     31                 {{- $label_text -}}
     32             </a>
     33             {{- end }}
     34 
     35             {{- $lsenabled := (or (not site.Params.disableThemeToggle) (and (not site.Params.disableLangToggle) (hugo.IsMultilingual))) }}
     36             {{- if $lsenabled }}
     37             <div class="logo-switches">
     38                 {{- if (not site.Params.disableThemeToggle) }}
     39                 <button id="theme-toggle" class="theme-toggle" accesskey="t" title="(Alt + T)" aria-label="Toggle theme">
     40                     <svg class="moon" xmlns="http://www.w3.org/2000/svg" width="17" height="17" viewBox="0 0 24 24"
     41                         fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
     42                         stroke-linejoin="round">
     43                         <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
     44                     </svg>
     45                     <svg class="sun" xmlns="http://www.w3.org/2000/svg" width="17" height="17" viewBox="0 0 24 24"
     46                         fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
     47                         stroke-linejoin="round">
     48                         <circle cx="12" cy="12" r="5"></circle>
     49                         <line x1="12" y1="1" x2="12" y2="3"></line>
     50                         <line x1="12" y1="21" x2="12" y2="23"></line>
     51                         <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
     52                         <line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
     53                         <line x1="1" y1="12" x2="3" y2="12"></line>
     54                         <line x1="21" y1="12" x2="23" y2="12"></line>
     55                         <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
     56                         <line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
     57                     </svg>
     58                 </button>
     59                 {{- end }}
     60 
     61                 {{- if (not site.Params.disableLangToggle) }}
     62                     {{- $lang := .Lang}}
     63                     {{- with site.Home.Translations }}
     64                     {{- $separator := or $label_text (not site.Params.disableThemeToggle)}}
     65                     {{- if $separator }}<span class="nav-sep">|</span>{{ end }}
     66                     <ul class="lang-menu">
     67                         {{- range . -}}
     68                         {{- if ne $lang .Lang }}
     69                         <li>
     70                             <a href="{{- .Permalink -}}" title="{{ .Language.Params.languageAltTitle | default (.Language.LanguageName | emojify) | default (.Lang | title) }}"
     71                                 aria-label="{{ .Language.LanguageName | default (.Lang | title) }}">
     72                                 {{- if (and site.Params.displayFullLangName (.Language.LanguageName)) }}
     73                                 {{- .Language.LanguageName | emojify -}}
     74                                 {{- else }}
     75                                 {{- .Lang | title -}}
     76                                 {{- end -}}
     77                             </a>
     78                         </li>
     79                         {{- end -}}
     80                         {{- end}}
     81                     </ul>
     82                     {{- end }}
     83                 {{- end }}
     84             </div>
     85             {{- end }}
     86         </div>
     87         {{- $currentPage := . }}
     88         <input id="menu-button" type="checkbox"/>
     89         <label id="menu-capture" for="menu-button"></label>
     90         <label id="menu-icon" for="menu-button"><span></span></label>
     91         <ul id="menu" class="menu">
     92             {{- range site.Menus.main }}
     93             {{- $menu_item_url := (cond (strings.HasSuffix .URL "/") .URL (printf "%s/" .URL) ) | absLangURL }}
     94             {{- $page_url:= $currentPage.Permalink | absLangURL }}
     95             {{- $is_search := eq (site.GetPage .KeyName).Layout `search` }}
     96             <li>
     97                 <a href="{{ .URL | absLangURL }}" title="{{ .Title | default .Name }} {{- cond $is_search (" (Alt + /)" | safeHTMLAttr) ("" | safeHTMLAttr ) }}"
     98                 {{- cond $is_search (" accesskey=/" | safeHTMLAttr) ("" | safeHTMLAttr ) }}>
     99                     <span {{- if eq $menu_item_url $page_url }} class="active" {{- end }}>
    100                         {{- .Pre }}
    101                         {{- .Name -}}
    102                         {{ .Post -}}
    103                     </span>
    104                     {{- if (findRE "://" .URL) }}&nbsp;
    105                     <svg fill="none" shape-rendering="geometricPrecision" stroke="currentColor" stroke-linecap="round"
    106                         stroke-linejoin="round" stroke-width="2.5" viewBox="0 0 24 24" height="12" width="12">
    107                         <path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"></path>
    108                         <path d="M15 3h6v6"></path>
    109                         <path d="M10 14L21 3"></path>
    110                     </svg>
    111                     {{- end }}
    112                 </a>
    113             </li>
    114             {{- end }}
    115         </ul>
    116     </nav>
    117 </header>