From 76678b55595595bc9313f78ae4290d1e3ae568d5 Mon Sep 17 00:00:00 2001 From: Vivek R Date: Mon, 30 Dec 2019 19:36:27 +0530 Subject: fix: disable disqus if Site.DisqusShortname is not set --- README.md | 2 +- layouts/_default/single.html | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 62a826c..be522bc 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ This is some static page where you can write about yourself. ## Disable Disqus -You can disable Disqus from contents selectively or for all contents with certain content type. Use content field `disqus` to disable Disqus from certain contents. +You can disable Disqus site wide if you don't set `DisqusShortname` param in config. You can also disable Disqus from contents selectively or for all contents with certain content type. Use content field `disqus` to disable Disqus from certain contents. ```md --- diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 2283e9a..4138ac7 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -27,19 +27,25 @@ {{ end }} {{ end }} - {{- $.Scratch.Set "isDisqus" true -}} + {{- if and (isset .Params "type") (in .Site.Params.disableDisqusTypes .Params.type) -}} {{- $.Scratch.Set "isDisqus" false -}} {{- end -}} + {{- if and (isset .Params "disqus") (eq .Params.disqus false) -}} {{- $.Scratch.Set "isDisqus" false -}} {{- else if and (isset .Params "disqus") (eq .Params.disqus true) -}} {{- $.Scratch.Set "isDisqus" true -}} {{- end -}} + + {{ if not .Site.DisqusShortname }} + {{- $.Scratch.Set "isDisqus" false -}} + {{ end }} + {{- if eq ($.Scratch.Get "isDisqus") true -}} {{- partial "disqus.html" . -}} {{- end -}} -- cgit v1.2.3