Fix error when there is no comment in staticman

Fixes #134
This commit is contained in:
tutysara 2018-02-13 00:47:46 +05:30 committed by GitHub
commit 05cf2daa26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,22 +13,23 @@
{{ else }} {{ else }}
<h3>{{ i18n "noComment" }}</h3> <h3>{{ i18n "noComment" }}</h3>
{{ end }} {{ end }}
{{ end }}
{{ $.Scratch.Set "hasComments" 0 }}
{{ range $index, $comments := (index $.Site.Data.comments $slug ) }} {{ $.Scratch.Set "hasComments" 0 }}
{{ if not .parent }} {{ range $index, $comments := (index $.Site.Data.comments $slug ) }}
{{ $.Scratch.Add "hasComments" 1 }} {{ if not .parent }}
<article id="comment-{{ $.Scratch.Get "hasComments" }}" class="static-comment"> {{ $.Scratch.Add "hasComments" 1 }}
<img class="comment-avatar" src="https://www.gravatar.com/avatar/{{ .email }}?s=48"> <article id="comment-{{ $.Scratch.Get "hasComments" }}" class="static-comment">
{{ if .website }} <img class="comment-avatar" src="https://www.gravatar.com/avatar/{{ .email }}?s=48">
<h4 class="comment-author"><a rel="external nofollow" href="{{ .website }}">{{ .name }}</a></h4> {{ if .website }}
{{ else }} <h4 class="comment-author"><a rel="external nofollow" href="{{ .website }}">{{ .name }}</a></h4>
<h4 class="comment-author">{{ .name }}</h4> {{ else }}
{{ end }} <h4 class="comment-author">{{ .name }}</h4>
<div class="comment-timestamp"><a href="#comment-{{ $.Scratch.Get "hasComments" }}" title="Permalink to this comment"><time datetime="{{ .date }}">{{ dateFormat (default (i18n "shortdateFormat") .Site.Params.dateformat) .date}}</time></a></div> {{ end }}
<div class="comment-content"><p>{{ .comment | markdownify }}</p></div> <div class="comment-timestamp"><a href="#comment-{{ $.Scratch.Get "hasComments" }}" title="Permalink to this comment"><time datetime="{{ .date }}">{{ dateFormat (default (i18n "shortdateFormat") .Site.Params.dateformat) .date}}</time></a></div>
</article> <div class="comment-content"><p>{{ .comment | markdownify }}</p></div>
</article>
{{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}