Procházet zdrojové kódy

fix: don't require site.Params.comments

Enable `comments` to be removed from `params.toml` for a site that doesn't use comments
George Cushen před 4 roky
rodič
revize
fa8e64327e

+ 3 - 1
wowchemy/layouts/partials/comments.html

@@ -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" . }}

+ 3 - 1
wowchemy/layouts/partials/page_metadata.html

@@ -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>