staticman-comments.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <section class="js-comments staticman-comments">
  2. {{ $slug := replace .RelPermalink "/" "" }}
  3. {{ if .Site.Data.comments }}
  4. {{ $comments := index $.Site.Data.comments $slug }}
  5. {{ if $comments }}
  6. {{ if gt (len $comments) 1 }}
  7. <h3>{{ len $comments }} {{ i18n "moreComment" }}</h3>
  8. {{ else }}
  9. <h3>{{ len $comments }} {{ i18n "oneComment" }}</h3>
  10. {{ end }}
  11. {{ else }}
  12. <h3>{{ i18n "noComment" }}</h3>
  13. {{ end }}
  14. {{ $.Scratch.Set "hasComments" 0 }}
  15. {{ range $index, $comments := (index $.Site.Data.comments $slug ) }}
  16. {{ if not .parent }}
  17. {{ $.Scratch.Add "hasComments" 1 }}
  18. <article id="comment-{{ $.Scratch.Get "hasComments" }}" class="static-comment">
  19. <img class="comment-avatar" src="https://www.gravatar.com/avatar/{{ .email }}?s=48">
  20. {{ if .website }}
  21. <h4 class="comment-author"><a rel="external nofollow" href="{{ .website }}">{{ .name }}</a></h4>
  22. {{ else }}
  23. <h4 class="comment-author">{{ .name }}</h4>
  24. {{ end }}
  25. <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>
  26. <div class="comment-content"><p>{{ .comment | markdownify }}</p></div>
  27. </article>
  28. {{ end }}
  29. {{ end }}
  30. {{ end }}
  31. <form class="js-form form" method="post" action="{{ .Site.Params.staticman.api }}">
  32. <input type="hidden" name="options[slug]" value="{{ replace .RelPermalink "/" "" }}">
  33. <input type="hidden" name="options[parent]" value="">
  34. {{ if .Site.Params.staticman.recaptcha }}
  35. <input type="hidden" name="options[reCaptcha][siteKey]" value="{{ .Site.Params.staticman.recaptcha.sitekey }}">
  36. <input type="hidden" name="options[reCaptcha][secret]" value="{{ .Site.Params.staticman.recaptcha.secret }}">
  37. {{ end }}
  38. <fieldset>
  39. <div class="textfield">
  40. <textarea name="fields[comment]" placeholder="{{ i18n "useMarkdown" }}"></textarea>
  41. </div>
  42. </fieldset>
  43. <fieldset>
  44. <div class="textfield">
  45. <input name="fields[name]" type="text" placeholder="{{ i18n "yourName" }}"/>
  46. </div>
  47. </fieldset>
  48. <fieldset>
  49. <div class="textfield">
  50. <input type="email" name="fields[email]" placeholder="{{ i18n "yourEmail" }}"/>
  51. </div>
  52. </fieldset>
  53. <fieldset>
  54. <div class="textfield">
  55. <input type="url" name="fields[website]" placeholder="{{ i18n "yourWebsite" }}"/>
  56. </div>
  57. </fieldset>
  58. {{ if .Site.Params.staticman.recaptcha }}
  59. <fieldset>
  60. <div class="g-recaptcha" data-sitekey="{{ .Site.Params.staticman.recaptcha.sitekey }}"></div>
  61. </fieldset>
  62. {{ end }}
  63. <fieldset>
  64. <button class="button">
  65. Submit
  66. </button>
  67. </fieldset>
  68. </form>
  69. </section>
  70. <article class="modal">
  71. <div class="title">
  72. <h2 class="js-modal-title"></h2>
  73. </div>
  74. <div class="js-modal-text"></div>
  75. <div>
  76. <button class="js-close-modal">Close</button>
  77. </div>
  78. </article>