Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CaiJimmy/hugo-theme-stack.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimmy Cai <jimmehcai@gmail.com>2020-09-11 23:50:30 +0300
committerJimmy Cai <jimmehcai@gmail.com>2020-09-11 23:50:30 +0300
commit6f5ee1bbdbca5254a12d9f09fe87ac29854a9b81 (patch)
tree37e64e814a26ee1845295e2a98fb03406a1b32b7
parentb064b5ef85a50ea353645a2b851e304e90176487 (diff)
refactor(head): rewrite title function
-rw-r--r--layouts/partials/data/title.html36
-rw-r--r--layouts/partials/head/head.html5
2 files changed, 32 insertions, 9 deletions
diff --git a/layouts/partials/data/title.html b/layouts/partials/data/title.html
index 91db60c..85a7bc7 100644
--- a/layouts/partials/data/title.html
+++ b/layouts/partials/data/title.html
@@ -1,16 +1,38 @@
{{- $title := .Title -}}
{{- $siteTitle := .Site.Title -}}
-{{- $authorName := .Site.Author.name -}}
{{- 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 }}{{ .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" -}}
- {{- $pag := .Paginate (where .Data.Pages "Type" "post") -}}
- {{ title .Data.Singular }}: {{ $title }}{{ if .Paginator.HasPrev }} - {{ .Paginator }}{{ end }} - {{ $siteTitle }}
-{{- else -}}
- {{- $title -}}
-{{- end -}} \ No newline at end of file
+ <!-- Taxonomy page -->
+
+ <!-- Build paginator -->
+ {{ $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 -}}
+
+{{ return $title }} \ No newline at end of file
diff --git a/layouts/partials/head/head.html b/layouts/partials/head/head.html
index 894c0bb..eb9cc0f 100644
--- a/layouts/partials/head/head.html
+++ b/layouts/partials/head/head.html
@@ -2,8 +2,9 @@
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<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 }}'>
{{- partial "head/style.html" . -}}