fix: disable disqus if Site.DisqusShortname is not set
This commit is contained in:
parent
972d3cef54
commit
76678b5559
@ -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
|
||||
---
|
||||
|
@ -27,19 +27,25 @@
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
{{- $.Scratch.Set "isDisqus" true -}}
|
||||
|
||||
<!-- Disable if content type is excluded in config -->
|
||||
{{- if and (isset .Params "type") (in .Site.Params.disableDisqusTypes .Params.type) -}}
|
||||
{{- $.Scratch.Set "isDisqus" false -}}
|
||||
{{- end -}}
|
||||
|
||||
<!-- Check if content has flag to enable/disable disqus explicitly -->
|
||||
{{- 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 -}}
|
||||
|
||||
<!-- Check if disqus short name is given -->
|
||||
{{ if not .Site.DisqusShortname }}
|
||||
{{- $.Scratch.Set "isDisqus" false -}}
|
||||
{{ end }}
|
||||
|
||||
{{- if eq ($.Scratch.Get "isDisqus") true -}}
|
||||
{{- partial "disqus.html" . -}}
|
||||
{{- end -}}
|
||||
|
Loading…
Reference in New Issue
Block a user