Improve logic in title template for less warnings
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
|
||||
<!-- RSS -->
|
||||
{{ with .OutputFormats.Get "rss" -}}
|
||||
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
|
||||
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
|
||||
{{ end -}}
|
||||
|
||||
{{ "<!--" | safeHTML }}
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user