From 26a6a0a7cd6601bc02ab3c55a6ec1dceafa8b969 Mon Sep 17 00:00:00 2001 From: John Tobin Date: Tue, 16 Jul 2019 00:42:28 +0100 Subject: [PATCH] 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. --- layouts/partials/posts/commento.html | 2 +- layouts/partials/posts/disqus.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/partials/posts/commento.html b/layouts/partials/posts/commento.html index 4889dc8..936f3bd 100644 --- a/layouts/partials/posts/commento.html +++ b/layouts/partials/posts/commento.html @@ -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) -}}
{{- end -}} diff --git a/layouts/partials/posts/disqus.html b/layouts/partials/posts/disqus.html index 2f1e5b4..c7471dd 100644 --- a/layouts/partials/posts/disqus.html +++ b/layouts/partials/posts/disqus.html @@ -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" . }} {{- end -}}