refactor(head): rewrite title function
This commit is contained in:
parent
b064b5ef85
commit
6f5ee1bbdb
@ -1,16 +1,38 @@
|
|||||||
{{- $title := .Title -}}
|
{{- $title := .Title -}}
|
||||||
{{- $siteTitle := .Site.Title -}}
|
{{- $siteTitle := .Site.Title -}}
|
||||||
{{- $authorName := .Site.Author.name -}}
|
|
||||||
|
|
||||||
{{- if .IsHome -}}
|
{{- if .IsHome -}}
|
||||||
|
<!-- Homepage, and it's pagination -->
|
||||||
|
|
||||||
|
<!-- Build paginator -->
|
||||||
{{ $pages := where .Site.RegularPages "Section" "in" .Site.Params.mainSections }}
|
{{ $pages := where .Site.RegularPages "Section" "in" .Site.Params.mainSections }}
|
||||||
{{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }}
|
{{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }}
|
||||||
{{ $filtered := ($pages | intersect $notHidden) }}
|
{{ $filtered := ($pages | intersect $notHidden) }}
|
||||||
{{ $pag := .Paginate ($filtered) }}
|
{{ $pag := .Paginate ($filtered) }}
|
||||||
{{ if .Paginator.HasPrev }}{{ .Paginator }} - {{ end }}{{ $siteTitle }}
|
|
||||||
|
{{ if .Paginator.HasPrev }}
|
||||||
|
<!-- Paginated. Append page number to title -->
|
||||||
|
{{ $title = printf "%s - %s" .Paginator $siteTitle }}
|
||||||
|
{{ else }}
|
||||||
|
{{ $title = $siteTitle}}
|
||||||
|
{{ end }}
|
||||||
{{- else if eq .Kind "term" -}}
|
{{- else if eq .Kind "term" -}}
|
||||||
{{- $pag := .Paginate (where .Data.Pages "Type" "post") -}}
|
<!-- Taxonomy page -->
|
||||||
{{ title .Data.Singular }}: {{ $title }}{{ if .Paginator.HasPrev }} - {{ .Paginator }}{{ end }} - {{ $siteTitle }}
|
|
||||||
{{- else -}}
|
<!-- Build paginator -->
|
||||||
{{- $title -}}
|
{{ $notHidden := where .Pages "Params.hidden" "!=" true }}
|
||||||
|
{{ $pag := .Paginate ($notHidden) }}
|
||||||
|
|
||||||
|
<!-- {TAXONOMY_TYPE}: {TAXONOMY_TERM} -->
|
||||||
|
{{ $title = slice (title .Data.Singular) ": " $title }}
|
||||||
|
|
||||||
|
{{ if .Paginator.HasPrev }}
|
||||||
|
<!-- Add page number-->
|
||||||
|
{{ $title = $title | append " - " .Paginator }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ $title = $title | append " - " $siteTitle }}
|
||||||
|
{{ $title = delimit $title "" }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
{{ return $title }}
|
@ -3,7 +3,8 @@
|
|||||||
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
||||||
<meta name='description' content='{{ chomp (partial "data/description" . | plainify ) }}'>
|
<meta name='description' content='{{ chomp (partial "data/description" . | plainify ) }}'>
|
||||||
|
|
||||||
<title>{{ (trim (partial "data/title" .) "\n" ) | safeHTML }}</title>
|
{{- $title := partial "data/title" . -}}
|
||||||
|
<title>{{ $title }}</title>
|
||||||
<link rel='canonical' href='{{ .Permalink }}'>
|
<link rel='canonical' href='{{ .Permalink }}'>
|
||||||
|
|
||||||
{{- partial "head/style.html" . -}}
|
{{- partial "head/style.html" . -}}
|
||||||
|
Loading…
Reference in New Issue
Block a user