hugo-hyperskip

Email-powered static comments for Hugo

git clone git://git.shimmy1996.com/hugo-hyperskip.git
commit 71e43130e9a09cd4a5c09daeb6b02e2d728b5ca8
parent 2cb6943b6dd9b8dcda7693a968d5346e621f7312
Author: Shimmy Xu <shimmy.xu@shimmy1996.com>
Date:   Sun, 17 May 2020 20:29:18 -0500

Use names instead of hashes for reply links

Diffstat:
Mlayouts/partials/comment_form.html | 4++--
Mlayouts/partials/list_comment.html | 13+++++++------
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/layouts/partials/comment_form.html b/layouts/partials/comment_form.html
@@ -14,7 +14,7 @@
   <p><input type="submit" value="{{ i18n "hyperskip-submit"}}"></p>
 </form>
 <script>
-  function reply(hash) {
-      document.forms.comment_form.comment.value += "[>>" + hash + "](#" + hash + ")\n";
+  function reply(hash, name) {
+      document.forms.comment_form.comment.value += "[Re: " + name + "](#" + hash + ")\n";
   }
 </script>
diff --git a/layouts/partials/list_comment.html b/layouts/partials/list_comment.html
@@ -6,16 +6,17 @@
 {{ range . }}
 {{ $timestamp := .time.Format "2006-01-02T15:04:05-07:00" }}
 {{ $hash := print .name $timestamp | md5 | last 7 }}
+{{ $name := or .name (i18n "hyperskip-name-default") }}
 <article id="{{ $hash }}">
   <header>
-    <a href="#{{ $hash }}">{{ $timestamp }}</a>&nbsp;|&nbsp;#{{ $hash }}
-    {{ if not ($.Scratch.Get "is_feed") }}
-    <span style="float:right">
-      <a href="#comment" onclick="reply({{ $hash }})">{{- i18n "hyperskip-reply" -}}</a>
-    </span>
+    <a href="#{{ $hash }}">{{ $timestamp }}</a>
+    {{- if not ($.Scratch.Get "is_feed") -}}
+    &nbsp;|&nbsp;<a href="#comment" onclick="reply({{ $hash }},{{ $name }})">
+      {{- i18n "hyperskip-reply" -}}
+    </a>
     {{ end }}
     <br/>
-    <b>{{- or .name (i18n "hyperskip-name-default") }}</b>&nbsp;
+    <b>{{ $name }}</b>&nbsp;
     {{- if (strings.HasSuffix ($.Site.Author.email | sha256) .email_hash) -}}
     ✦{{ else }}<code>{{ .email_hash | last 4 }}</code>
     {{- end -}}