You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
7.6 KiB
HTML

{{ $page := . }}
{{ $basepath := path.Clean (urls.Parse (relLangURL "")).Path }}
{{ $breadcrumbs := $page.Ancestors | and ($page.Param "paige.site.disable_breadcrumbs" | not) }}
{{ $description := $page.Param "paige.description" | markdownify | and ($page.Param "paige.site.disable_description" | not) }}
{{ $first := templates.Exists "partials/paige/site-header-first.html" }}
{{ $last := templates.Exists "partials/paige/site-header-last.html" }}
{{ $links := false }}
{{ $menu := $page.Param "paige.site.disable_menu" | not }}
{{ $pills := false }}
{{ $tabs := false }}
{{ $title := $page.Param "paige.title" | default site.Title | markdownify | and ($page.Param "paige.site.disable_title" | not) }}
{{ $underline := false }}
{{ if eq $basepath "/" }}
{{ $basepath = "" }}
{{ end }}
{{ $pagepath := strings.TrimPrefix $basepath $page.RelPermalink }}
{{ with $page.Param "paige.menu_style" }}
{{ if eq . "pills" }}
{{ $pills = true }}
{{ else if eq . "tabs" }}
{{ $tabs = true }}
{{ else if eq . "underline" }}
{{ $underline = true }}
{{ else }}
{{ $links = true }}
{{ end }}
{{ else }}
{{ $links = true }}
{{ end }}
{{ if or $breadcrumbs $description $first $last $menu $title }}
<header id="paige-site-header">
{{ if $first }}
{{ partial "paige/site-header-first.html" $page }}
{{ end }}
{{ with $title }}
<div class="display-1 fw-bold {{ if $description }} mb-2 {{ end }} paige-row-wide text-center" id="paige-site-title">{{ . }}</div>
{{ end }}
{{ with $description }}
<div class="lead paige-row-wide text-center" id="paige-site-description">{{ . }}</div>
{{ end }}
{{ if $menu }}
{{ with site.Menus.main }}
<nav aria-label="{{ i18n `paige_menu` }}" class="paige-row-wide" id="paige-menu">
<ul class="align-items-center justify-content-center nav {{ if $pills }} nav-pills {{ else if $tabs }} nav-tabs {{ else if $underline }} nav-underline {{ end }}">
{{ range . }}
{{ $menupath := strings.TrimPrefix $basepath .URL }}
{{ $home := and (eq $menupath "/") (eq $pagepath "/") }}
{{ $menuprefix := and (ne $menupath "/") (hasPrefix $pagepath $menupath) }}
{{ $sectionprefix := and (ne $menupath "/") (hasPrefix $menupath (printf "/%s/" $page.Section)) }}
{{ $active := or $home $menuprefix $sectionprefix }}
<li class="nav-item {{ if .Children }} dropdown {{ end }}">
<a {{ if $active }} aria-current="page" {{ end }} {{ if .Children }} aria-expanded="false" {{ end }} class="{{ if $active }} active {{ if $links }} fw-bold text-body-emphasis {{ end }} {{ end }} {{ if .Params.paige.disabled }} disabled {{ end }} nav-link {{ if .Children }} dropdown-toggle {{ end }} {{ if $links }} text-decoration-underline {{ end }}" {{ if .Children }} data-bs-toggle="dropdown" {{ end }} href="{{ if .Children -}} # {{- else -}} {{ .URL | safeURL }} {{- end }}" {{ if .Children }} role="button" {{ end }} {{ if not .Children }} {{ with partial "paige/target.html" (dict "page" $page "url" .URL) }} target="{{ . }}" {{ end }} {{ end }}>{{ .Name }}</a>
{{ with .Children }}
<ul class="dropdown-menu">
{{ range . }}
{{ if .Params.paige.divider_above }}
<li>
<hr class="dropdown-divider">
</li>
{{ end }}
<li>
<a class="{{ if .Params.paige.disabled }} disabled {{ end }} dropdown-item" href="{{ .URL | safeURL }}" {{ with partial "paige/target.html" (dict "page" $page "url" .URL) }} target="{{ . }}" {{ end }}>{{ .Name }}</a>
</li>
{{ if .Params.paige.divider_below }}
<li>
<hr class="dropdown-divider">
</li>
{{ end }}
{{ end }}
</ul>
{{ end }}
</li>
{{ end }}
</ul>
</nav>
{{ else }}
{{ $ordered := slice site.Home | append site.Sections }}
{{ range $name, $taxonomy := site.Taxonomies }}
{{ if and $taxonomy.Page $taxonomy.Page.RelPermalink }}
{{ $ordered = $ordered | append $taxonomy.Page }}
{{ end }}
{{ end }}
{{ $ordered = sort $ordered "Title" }}
<nav aria-label="{{ i18n `paige_menu` }}" class="paige-row-wide" id="paige-menu">
<ul class="align-items-center justify-content-center nav {{ if $pills }} nav-pills {{ else if $tabs }} nav-tabs {{ else if $underline }} nav-underline {{ end }}">
{{ range $ordered }}
{{ $menupath := strings.TrimPrefix $basepath .RelPermalink }}
{{ $home := and (eq $menupath "/") (eq $pagepath "/") }}
{{ $menuprefix := and (ne $menupath "/") (hasPrefix $pagepath $menupath) }}
{{ $sectionprefix := and (ne $menupath "/") (hasPrefix $menupath (printf "/%s/" $page.Section)) }}
{{ $active := or $home $menuprefix $sectionprefix }}
<li class="nav-item">
<a {{ if $active }} aria-current="page" {{ end }} class="{{ if $active }} active {{ if $links }} fw-bold text-body-emphasis {{ end }} {{ end }} nav-link {{ if $links }} text-decoration-underline {{ end }}" href="{{ .RelPermalink | safeURL }}" {{ with partial "paige/target.html" (dict "page" $page "url" .RelPermalink) }} target="{{ . }}" {{ end }}>{{ .Title }}</a>
</li>
{{ end }}
</ul>
</nav>
{{ end }}
{{ end }}
{{ with $breadcrumbs }}
<nav aria-label="{{ i18n `paige_breadcrumbs` }}" class="paige-row-wide" id="paige-breadcrumbs">
<div class="d-flex justify-content-center">
<ol class="breadcrumb mb-0">
{{ $reverse := .Reverse }}
{{ $last := sub (len $reverse) 1 }}
{{ range $i, $ancestor := $reverse }}
{{ $title := $ancestor.Title }}
{{ if and (eq $i $last) (not $title) }}
{{ $title = $page.Param "paige.title" | default (site.Title) }}
{{ end }}
<li class="breadcrumb-item"><a href="{{ .RelPermalink }}">{{ $title | markdownify | plainify | htmlUnescape }}</a></li>
{{ end }}
</ol>
</div>
</nav>
{{ end }}
{{ if $last }}
{{ partial "paige/site-header-last.html" $page }}
{{ end }}
</header>
{{ end }}