-
Notifications
You must be signed in to change notification settings - Fork 13
/
post-comments.html
46 lines (39 loc) · 2.03 KB
/
post-comments.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<section class="post-comments">
<h3>Comments</h3>
{{ $comments := readDir "data/comments" }}
{{ $.Scratch.Add "hasComments" 0 }}
{{ $entryId := .UniqueID }}
{{ range $comments }}
{{ if eq .Name $entryId }}
{{ $.Scratch.Add "hasComments" 1 }}
{{ range $index, $comments := (index $.Site.Data.comments $entryId ) }}
<div class="post-comment">
<div class="post-comment-header">
<img class="post-comment-avatar" src="https://www.gravatar.com/avatar/{{ .email }}?s=100">
<p class="post-comment-info"><strong>{{ .name }}</strong><br>{{ dateFormat "02/01/2006" .date }}</p>
</div>
{{ .body | markdownify }}
</div>
{{ end }}
{{ end }}
{{ end }}
{{ if eq ($.Scratch.Get "hasComments") 0 }}
<p>Nothing yet.</p>
{{ end }}
<h3>Say something</h3>
<form class="post-new-comment" method="POST" action="https://dev.staticman.net/v2/entry/eduardoboucas/hugo-plus-staticman/master/comments">
<!--form class="post-new-comment" method="POST" action="http://localhost:8055/v2/entry/eduardoboucas/staticman-test/master/comments"-->
<input type="hidden" name="options[redirect]" value="{{ .Permalink }}#comment-submitted">
<input type="hidden" name="options[entryId]" value="{{ .UniqueID }}">
<input name="fields[name]" type="text" class="post-comment-field" placeholder="Your name">
<input name="fields[email]" type="email" class="post-comment-field" placeholder="Your email address">
<textarea name="fields[body]" class="post-comment-field" placeholder="Your message. Feel free to use Markdown." rows="10"></textarea>
<input type="submit" class="post-comment-field btn" value="Submit">
</form>
</section>
<div id="comment-submitted" class="dialog">
<h3>Thank you</h3>
<p>Your comment has been submitted and will be published once it has been approved.</p>
<p><a href="https://github.com/eduardoboucas/hugo-plus-staticman/pulls">Click here</a> to see the pull request you generated.</p>
<p><a href="#" class="btn">OK</a></p>
</div>