Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
65 lines (60 sloc) 2.65 KB
<section class="post-comments">
{{ $temp := (replace .URL "/" "") | replaceRE `^([1-2][0-9])\d\d(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])` "" }}
{{ $temp2 := .File.BaseFileName }}
{{ if eq .File.BaseFileName "index" }}
{{ $.Scratch.Add "entryId" $temp }}
{{ else }}
{{ $.Scratch.Add "entryId" $temp2 }}
{{ end }}
{{ if .Site.Data.comments }}
{{ $comments := index $.Site.Data.comments ($.Scratch.Get "entryId") }}
{{ if $comments }}
{{ if gt (len $comments) 1 }}
<h3>{{ len $comments }} {{ i18n "moreComment" }}</h3>
{{ else }}
<h3>{{ len $comments }} {{ i18n "oneComment" }}</h3>
{{ end }}
{{ else }}
<h3>{{ i18n "noComment" }}</h3>
{{ end }}
{{ $.Scratch.Set "hasComments" 0 }}
{{ range $comments }}
{{ $.Scratch.Add "hasComments" 1 }}
{{ if not .reply_to }}
{{ $.Scratch.Set "parentId" ._id }}
{{ $.Scratch.Set "parentName" .name }}
{{ $.Scratch.Set "hasReplies" 0 }}
<div class="post-comment-header">
<img class="post-comment-avatar" src="https://www.gravatar.com/avatar/{{ .email }}?s=70">
<p class="post-comment-info"><strong>{{ .name }}</strong><br><small>{{ dateFormat "Monday, Jan 2, 2006" .date }}</small></p>
</div>
<div class="post-comment">
{{ .body | markdownify }}
</div>
<div class="post-comment-reply-button">
<a id="{{ ._id }}" class="btn-info" href="#comment-form" onclick="changeValue('fields[reply_to]', '{{ ._id }}')">Reply to {{ .name }}</a>
</div>
<div style="clear: both;"></div>
{{ range $comments }}
{{ if eq .reply_to ( $.Scratch.Get "parentId" ) }}
{{ $.Scratch.Add "hasReplies" 1 }}
<div class="post-comment-header">
<img class="post-comment-avatar-reply" src="https://www.gravatar.com/avatar/{{ .email }}?s=70">
<p class="post-comment-info"><strong>{{ .name }}</strong><br><i><small>In reply to {{ ( $.Scratch.Get "parentName" ) }}</i><br>{{ dateFormat "Monday, Jan 2, 2006" .date }}</small></p>
</div>
<div class="post-comment-reply">
{{ .body | markdownify }}
</div>
{{ end }}
{{ end }}
{{ if gt ($.Scratch.Get "hasReplies") 0 }}
<div class="post-comment-reply-button-reply">
<a id="{{ ._id }}" class="btn-info" href="#comment-form" onclick="changeValue('fields[reply_to]', '{{ ._id }}')">Reply to Thread</a>
</div>
<div style="clear: both;"></div>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ partial "comment_form" . }}
</section>