fix: don't require site.Params.comments

Enable `comments` to be removed from `params.toml` for a site that doesn't use comments
This commit is contained in:
George Cushen 2020-10-24 19:47:55 +01:00
commit fa8e64327e
2 changed files with 6 additions and 2 deletions

View file

@ -1,4 +1,6 @@
{{ if site.Params.comments.engine | and (index site.Params.comments.commentable .Type) | and (ne .Params.commentable false) | or .Params.commentable }}
{{ $commentable_map := site.Params.comments.commentable | default dict }}
{{ $commentable_bool := index $commentable_map .Type | default false }}
{{ if site.Params.comments.engine | and $commentable_bool | and (ne .Params.commentable false) | or .Params.commentable }}
<section id="comments">
{{ if eq site.Params.comments.engine 1 }}
{{ partial "comments/disqus.html" . }}

View file

@ -46,7 +46,9 @@
{{ end }}
{{/* Show Disqus comment count if enabled. */}}
{{ $disqus_enabled := eq site.Params.comments.engine 1 | and (index site.Params.comments.commentable $page.Type) | and (ne $page.Params.commentable false) | or $page.Params.commentable }}
{{ $commentable_map := site.Params.comments.commentable | default dict }}
{{ $commentable_bool := index $commentable_map $page.Type | default false }}
{{ $disqus_enabled := eq site.Params.comments.engine 1 | and $commentable_bool | and (ne $page.Params.commentable false) | or $page.Params.commentable }}
{{ if and $disqus_enabled (site.Params.comments.disqus.show_count | default true) }}
<span class="middot-divider"></span>
<a href="{{ $page.RelPermalink }}#disqus_thread"><!-- Count will be inserted here --></a>