Add staticman support (static comments coupled with Github pull request)
This commit is contained in:
parent
7cdd0e0b3d
commit
8a0d06525d
16 changed files with 264 additions and 7 deletions
84
layouts/partials/staticman-comments.html
Normal file
84
layouts/partials/staticman-comments.html
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
<section class="js-comments staticman-comments">
|
||||
<h3>Comments</h3>
|
||||
|
||||
{{ $slug := replace .URL "/" "" }}
|
||||
{{ $.Scratch.Add "hasComments" 0 }}
|
||||
|
||||
<!-- Parse all parent comment -->
|
||||
{{ range $index, $comments := (index $.Site.Data.comments $slug ) }}
|
||||
<!-- Check if comment has 0 parent -->
|
||||
{{ if eq $index "0" }}
|
||||
{{ range $comments}}
|
||||
{{ $.Scratch.Add "hasComments" 1 }}
|
||||
<article id="comment-{{ $.Scratch.Get "hasComments" }}" class="static-comment">
|
||||
<img class="comment-avatar" src="https://www.gravatar.com/avatar/{{ .email }}?s=48">
|
||||
{{ if .website }}
|
||||
<h4 class="comment-author"><a rel="external nofollow" href="{{ .website }}">{{ .name }}</a></h4>
|
||||
{{ else }}
|
||||
<h4 class="comment-author">{{ .name }}</h4>
|
||||
{{ end }}
|
||||
<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>
|
||||
<div class="comment-content"><p>{{ .comment | markdownify }}</p></div>
|
||||
</article>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
|
||||
<form class="js-form form" method="post" action="{{ .Site.Params.staticman.api}}">
|
||||
<input type="hidden" name="options[slug]" value="{{ replace .URL "/" "" }}">
|
||||
<input type="hidden" name="options[parent]" value="0">
|
||||
|
||||
{{ if .Site.Params.staticman.recaptcha }}
|
||||
<input type="hidden" name="options[reCaptcha][siteKey]" value="{{ .Site.Params.staticman.recaptcha.sitekey }}">
|
||||
<input type="hidden" name="options[reCaptcha][secret]" value="{{ .Site.Params.staticman.recaptcha.secret }}">
|
||||
{{ end }}
|
||||
|
||||
<fieldset>
|
||||
<div class="textfield">
|
||||
<textarea name="fields[comment]" type="text" placeholder="You can use Markdown syntax"></textarea>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<div class="textfield">
|
||||
<input name="fields[name]" type="text" placeholder="Your name"/>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<div class="textfield">
|
||||
<input type="email" name="fields[email]" placeholder="Your email (optional, used only to send comments.)"/>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<div class="textfield">
|
||||
<input type="text" name="fields[website]" placeholder="Your website"/>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
{{ if .Site.Params.staticman.recaptcha }}
|
||||
<fieldset>
|
||||
<div class="g-recaptcha" data-sitekey="{{ .Site.Params.staticman.recaptcha.sitekey }}"></div>
|
||||
</fieldset>
|
||||
{{ end }}
|
||||
|
||||
<fieldset>
|
||||
<button class="button">
|
||||
Submit
|
||||
</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<article class="modal">
|
||||
<div class="title">
|
||||
<h2 class="js-modal-title"></h2>
|
||||
</div>
|
||||
<div class="js-modal-text"></div>
|
||||
<div>
|
||||
<button class="js-close-modal">Close</button>
|
||||
</div>
|
||||
</article>
|
||||
Loading…
Add table
Add a link
Reference in a new issue