Skip to content

Commit

Permalink
Bug Fix: Empty .Site.Params.contentDir (#312)
Browse files Browse the repository at this point in the history
* 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/
  • Loading branch information
jasikpark authored Feb 22, 2021
1 parent 27c1791 commit 9791db1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion layouts/partials/docs/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 9791db1

Please sign in to comment.