Simplify if condition, and format code

This commit is contained in:
Jimmy Cai 2021-08-15 16:53:12 +00:00 committed by GitHub
parent c7dd876bb1
commit 0b3ff067d9

View File

@ -1,19 +1,19 @@
<div class="disqus-container"> <div class="disqus-container">
{{- $pc := .Site.Config.Privacy.Disqus -}} {{- $pc := .Site.Config.Privacy.Disqus -}}
{{- $disqusjs := .Site.Params.Comments.Disqusjs -}} {{- $disqusjs := .Site.Params.Comments.Disqusjs -}}
{{- if not $pc.Disable -}} {{- if and (not $pc.Disable) (and $disqusjs.Shortname $disqusjs.ApiKey) -}}
{{ if and $disqusjs.Shortname $disqusjs.ApiKey }}<div id="disqus_thread"></div> <div id="disqus_thread"></div>
<script type="application/javascript"> <script type="application/javascript">
var disqusjs; var disqusjs;
function loadDisqusJS() { function loadDisqusJS() {
disqusjs = new DisqusJS({ disqusjs = new DisqusJS({
shortname: {{ $disqusjs.Shortname }}, shortname: {{ $disqusjs.Shortname }},
siteName: {{ .Site.Title }}, siteName: {{ .Site.Title }},
apikey: {{ $disqusjs.ApiKey }}, apikey: {{ $disqusjs.ApiKey }},
{{ with $disqusjs.ApiUrl }}api: {{ . }},{{ end }} {{ with $disqusjs.ApiUrl }}api: {{ . }},{{ end }}
{{ with $disqusjs.Admin }}admin: {{ . }},{{ end }} {{ with $disqusjs.Admin }}admin: {{ . }},{{ end }}
{{ with $disqusjs.AdminLabel }}adminLabel: {{ . }}{{ end }} {{ with $disqusjs.AdminLabel }}adminLabel: {{ . }}{{ end }}
}); });
} }
function lazyLoadDisqusJS() { function lazyLoadDisqusJS() {
@ -53,6 +53,5 @@
} }
</script> </script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
{{end}}
{{- end -}} {{- end -}}
</div> </div>