Improve logic in title template for less warnings

This commit is contained in:
Alex Shpak
2019-04-22 22:19:08 +02:00
parent 0b30289d9f
commit b10d1e959c
7 changed files with 14 additions and 8 deletions
+5 -3
View File
@@ -1,12 +1,14 @@
{{/*These templates contains some more complex logic and shared between partials*/}}
{{ define "title" }}
{{ if and .File .Pages }}
{{ if and .IsSection .File }}
{{ $sections := split (trim .File.Dir "/") "/" }}
{{ $title := index ($sections | last 1) 0 | humanize | title }}
{{ default $title .Title }}
{{ else if .File }}
{{ $title := .File.BaseFileName | humanize | title }}
{{ else if and .IsPage .File }}
{{ $title := .File.BaseFileName | humanize | title }}
{{ default $title .Title }}
{{ else }}
{{ .Title }}
{{ end }}
{{ end }}