Check if commentoUrl is set before using it. (#198)

* Check if commentoUrl is set before using it.

When a variable does not exist it evaluates to `nil`, and so the
check `(not (eq .Site.Params.commentoUrl ""))` evaluates to true rather
than false because `nil` is not "".  Before this change, unless you
explicitly set Params.commentoUrl to "", the commento HTML block would
be added, and this fails because /js/commento.js does not exist.  This
change ensures that the commento HTML block is only added whe
Params.commentoUrl exists and is set to a non-empty string.

* Check if DisqusShortname is set before using it.
This commit is contained in:
John Tobin 2019-07-16 00:42:28 +01:00 committed by Luiz F. A. de Prá
parent a1afda5d22
commit 26a6a0a7cd
2 changed files with 2 additions and 2 deletions

View File

@ -1,4 +1,4 @@
{{- if and (not (eq .Site.Params.commentoUrl "" )) (eq (.Params.disable_comments | default false) false) -}} {{- if and (isset .Site.Params "commentourl") (not (eq .Site.Params.commentoUrl "" )) (eq (.Params.disable_comments | default false) false) -}}
<div id="commento"></div> <div id="commento"></div>
<script src="{{ .Site.Params.commentoUrl }}/js/commento.js"></script> <script src="{{ .Site.Params.commentoUrl }}/js/commento.js"></script>
{{- end -}} {{- end -}}

View File

@ -1,3 +1,3 @@
{{- if and (not (eq .Site.DisqusShortname "" )) (eq (.Params.disable_comments | default false) false) -}} {{- if and (isset .Site "disqusshortname") (not (eq .Site.DisqusShortname "" )) (eq (.Params.disable_comments | default false) false) -}}
{{ template "_internal/disqus.html" . }} {{ template "_internal/disqus.html" . }}
{{- end -}} {{- end -}}