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
+1 -1
View File
@@ -9,7 +9,7 @@
<body>
<main class="flex justify-center">
<h1>404 Not Found</h1>
<h1>404 Not Found</h1>
</main>
{{ partial "docs/inject/body" . }}
+1 -1
View File
@@ -17,7 +17,7 @@ You can override this page in:
` }}
<body>
<main class="flex justify-center">
<div class="book-page markdown">
<div class="book-home markdown">
{{ replace $content "&#96;" "`" | markdownify }}
</div>
</main>
+1 -1
View File
@@ -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 }}
+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 }}