camp-homepage/gallery/themes/autophugo/layouts/partials/header.html
Christoph Schindlbeck 0a88edb862 don't parse numbers in album titles
e.g. '2022' -> '2020nd'
2023-02-09 22:53:36 +01:00

42 lines
2.0 KiB
HTML

<header id="header">
<h1>
<!-- Grab the base URL, pull out the path, then count directories -->
{{- $base_url_parsed := urls.Parse .Site.BaseURL -}}
{{- $base_dir := trim $base_url_parsed.Path "/" -}}
{{- $base_part_cnt := cond (ne $base_dir "") (len (split $base_dir "/" )) 0 -}}
<!-- Grab the current URL, separate it out -->
{{- $url_parsed := urls.Parse .Permalink -}}
{{- $trimmed_url := trim $url_parsed.Path "/" -}}
{{- $pre_url_parts := split $trimmed_url "/" -}}
{{- $pre_part_count := len $pre_url_parts -}}
<!-- Drop the part of the current URL that's the base URL -->
{{- $url_parts := last (sub $pre_part_count $base_part_cnt) $pre_url_parts -}}
{{- $part_count := len $url_parts -}}
<!-- Determine how much of the URL to use (sometimes last part is blank) -->
{{- $last_part := index $url_parts (sub $part_count 1) -}}
{{- $use_part_cnt := cond (eq (trim $last_part " ") "") (sub $part_count 1) $part_count -}}
<!-- Determine whether to use URL components or titles for breadcrumb -->
{{- $crumb_is_title := .Site.Params.breadcrumb_use_title | default false -}}
<!-- Build the breadcrumb - base URL link, path links for each dir, cur location text -->
{{ $url := urls.Parse $.Site.BaseURL }}
<a href="{{ $url.Scheme }}://{{ $url.Host }}"><strong>{{ .Site.Title }}</strong></a>
/ <a href="{{ $.Site.BaseURL }}"><strong>Gallery</strong></a>
{{- if gt $use_part_cnt 0 -}}
{{- range $cur_ind, $element := first (sub $use_part_cnt 1) $url_parts -}}
{{- $path := string (delimit (first (add $cur_ind 1) $url_parts) "/") -}}
{{- $part := $element | humanize }}
/ <a href="{{ $.Site.BaseURL }}{{ $path }}"><strong>{{ cond $crumb_is_title ((($.Site.GetPage $path).Title) | default $part) $part }}</strong></a>
{{- end -}}
{{- $cur_part := (index $url_parts (sub $use_part_cnt 1)) }}
/ {{ cond $crumb_is_title (.Title | default $cur_part) $cur_part }}
{{- end }}
</h1>
{{ partial "navigation.html" . }}
</header>