Hello,
I am using staticman to add comments to a website. Comments get pushed to /data/comments
directory as yml files.
data/
`-- comments
|-- comment-1640218313969.yml
`-- comment-1640227930656.yml
Here is comment-1640218313969.yml
_id: ee656ca0-6384-11ec-b29c-9f0b89f5415e
name: testy
email: b642b4217b34b1e8d3bd915fc65c4452
comment: number one comment.
date: '2021-12-23T00:11:53.964Z'
I am trying to use a partial to show the submitted comments, as described here.
{{ $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 ) }}
<blockquote>
<p>{{ .comment | markdownify }}</p>
<cite>
<strong>{{ .name }}</strong><br>{{ dateFormat "02/01/2006" .date }}
</cite>
</blockquote>
{{ end }}
{{ end }}
{{ end }}
{{ if eq ($.Scratch.Get "hasComments") 0 }}
<p>Hey, be the first who comment this article.</p>
{{ end }}
I am unable to display any comments that are stored in /data/comments
.
Thank you for any help understanding what I need to make this work.