header.html (1720B)
1 {{- /* 2 Site header — brand (user@host ~/path) + nav. 3 4 The first nav slot is always the home link; its label comes from 5 `site.Params.brandLabel` (default "whoami"). The remaining slots iterate 6 over `site.Menus.main` — add or remove menu entries in your hugo.toml 7 to change the nav. 8 9 Context: 10 .page — the current Page (for active-state detection) 11 .path — string after `~/` in the brand line (e.g. "posts") 12 .mobileWord — slice of single chars for the mobile dot-matrix marker 13 */ -}} 14 {{- $page := .page -}} 15 {{- $path := .path -}} 16 {{- $user := site.Params.brandUser | default "user" -}} 17 {{- $host := site.Params.brandHost | default "example.com" -}} 18 {{- $brandLabel := site.Params.brandLabel | default "whoami" -}} 19 <header class="site"> 20 <div class="brand"> 21 <a class="brand-link" href="{{ "/" | relURL }}" aria-label="{{ $brandLabel }}"><span class="user">{{ $user }}</span><span class="at">@</span><span class="host">{{ $host }}</span></a><span class="path"> ~/{{ $path }}</span> 22 </div> 23 <nav class="site"> 24 <a href="{{ "/" | relURL }}"{{ if $page.IsHome }} class="is-active"{{ end }}>{{ $brandLabel }}</a> 25 {{- range site.Menus.main }} 26 {{- $url := .URL | relURL -}} 27 {{- $isActive := false -}} 28 {{- if eq $page.RelPermalink $url -}}{{- $isActive = true -}}{{- end -}} 29 {{- if and (ne $url "/") (hasPrefix $page.RelPermalink $url) -}}{{- $isActive = true -}}{{- end -}} 30 <a href="{{ $url }}"{{ if $isActive }} class="is-active"{{ end }}>{{ .Name }}</a> 31 {{- end }} 32 </nav> 33 {{- with .mobileWord -}} 34 {{ partial "cyrillic-svg.html" (dict "word" . "W" 320 "H" 26 "class" "frame-marker frame-marker-mobile") }} 35 {{- end -}} 36 </header>