hugo-hyperskip

Email-powered static comments for Hugo

git clone git://git.shimmy1996.com/hugo-hyperskip.git
commit ee6768cb08b414a9fc71b0dac69a5a615fc625e6
parent c4b19d807c010c7d2bb55d8ba20007a78410c543
Author: Shimmy Xu <shimmy.xu@shimmy1996.com>
Date:   Tue,  7 Jan 2020 18:19:04 -0600

Add placeholder text for use with web feeds

Diffstat:
Mi18n/en.toml | 7+++++--
Mi18n/zh.toml | 7+++++--
Mlayouts/partials/list_comment.html | 8+++++++-
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/i18n/en.toml b/i18n/en.toml
@@ -17,4 +17,7 @@ other = "Email Comment"
 other = "Reply"
 
 [hyperskip-requirement]
-other = "At least 3 characters. Markdown is supported."-
\ No newline at end of file
+other = "At least 3 characters. Markdown is supported."
+
+[hyperskip-placeholder]
+other = "No comments yet."+
\ No newline at end of file
diff --git a/i18n/zh.toml b/i18n/zh.toml
@@ -17,4 +17,7 @@ other = "使用电子邮件提交"
 other = "回复"
 
 [hyperskip-requirement]
-other = "至少三个字符。支持 Markdown 语法。"-
\ No newline at end of file
+other = "至少三个字符。支持 Markdown 语法。"
+
+[hyperskip-placeholder]
+other = "暂时没有评论。"+
\ No newline at end of file
diff --git a/layouts/partials/list_comment.html b/layouts/partials/list_comment.html
@@ -1,5 +1,9 @@
+{{ $comments := "" }}
 {{ with .Site.Data.comments.comments }}
-{{ range sort (where . "uri" $.Page.RelPermalink) "time" }}
+{{ $comments = sort (where . "uri" $.Page.RelPermalink) "time" }}
+{{ end }}
+{{ with $comments }}
+{{ range . }}
 {{ $timestamp := .time.Format "2006-01-02T15:04:05-07:00" }}
 {{ $hash := print .name $timestamp | md5 | last 7 }}
 <article id="{{ $hash }}">
@@ -28,4 +32,6 @@
       document.forms.comment_form.comment.value += "[>>" + hash + "](#" + hash + ")\n";
   }
 </script>
+{{ else }}
+<p>{{ i18n "hyperskip-placeholder" }}</p>
 {{ end }}