Bug Fix: Empty .Site.Params.contentDir (#312)

* Bug Fix: Empty .Site.Params.contentDir

When .Site.Params.contentDir is left as the default: "content", calling .Site.Params.contentDir returns nothing, or maybe an empty string. To fix this, we set a default value for .Site.Params.contentDir to "content" and the url is built correctly.

* Use the `default` function instead of `or`

https://gohugo.io/functions/default/
This commit is contained in:
Caleb Jasik 2021-02-22 12:48:49 -06:00 committed by GitHub
parent 27c1791144
commit 9791db1ce7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,7 +15,7 @@
{{ if and .File .Site.Params.BookRepo .Site.Params.BookEditPath }}
<div>
<a class="flex align-center" href="{{ .Site.Params.BookRepo }}/{{ .Site.Params.BookEditPath }}/{{ .Site.Params.contentDir }}/{{ replace .File.Path "\\" "/" }}" target="_blank" rel="noopener">
<a class="flex align-center" href="{{ .Site.Params.BookRepo }}/{{ .Site.Params.BookEditPath }}/{{ .Site.Params.contentDir | default "content" }}/{{ replace .File.Path "\\" "/" }}" target="_blank" rel="noopener">
<img src="{{ "svg/edit.svg" | relURL }}" class="book-icon" alt="Edit" />
<span>{{ i18n "Edit this page" }}</span>
</a>