hugo-theme-stack/layouts/partials/data/title.html
2024-07-11 16:25:15 +03:00

49 lines
No EOL
1.6 KiB
HTML

{{- $title := .Title -}}
{{- $siteTitle := .Site.Title -}}
{{- if .IsHome -}}
<!-- Homepage, and it's pagination -->
<!-- Build paginator -->
{{ $pages := where .Site.RegularPages "Section" "in" .Site.Params.mainSections }}
{{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }}
{{ $filtered := ($pages | intersect $notHidden) }}
{{ $pag := .Paginate ($filtered) }}
{{ if .Paginator.HasPrev }}
<!-- Paginated. Append page number to title -->
{{ $title = printf "%s - %s" .Paginator $siteTitle }}
{{ else }}
{{ $title = $siteTitle}}
{{ end }}
{{- else if eq .Kind "term" -}}
<!-- Taxonomy page -->
<!-- Build paginator -->
{{ $notHidden := where .Pages "Params.hidden" "!=" true }}
{{ $pag := .Paginate ($notHidden) }}
<!-- {TAXONOMY_TYPE}: {TAXONOMY_TERM} -->
{{ $taxonomyTerm := .Title }}
{{ $taxonomyType := T (printf "list.%s" .Data.Singular | urlize | lower) }}
{{ if eq (lower .Section) "tags" }}
{{ $translatedTag := T (printf "tags.%s" $taxonomyTerm | urlize | lower) }}
{{ $taxonomyTerm = $translatedTag | default $taxonomyTerm }}
{{ end }}
{{ $title = slice (title $taxonomyType) ": " $taxonomyTerm }}
{{ if .Paginator.HasPrev }}
<!-- Add page number-->
{{ $title = $title | append " - " .Paginator }}
{{ end }}
{{ $title = $title | append " - " $siteTitle }}
{{ $title = delimit $title "" }}
{{- else if eq .Kind "taxonomy" -}}
<!-- Taxonomy overview page (e.g., /tags/, /categories/) -->
{{ $title = T (printf "list.%s" $title | urlize | lower) }}
{{- end -}}
{{ return $title }}