It’s not yet live on my site (still need to do the disqus import), but I’ve been working on something like this.
Basically I create comment files under /content/comment/test.md for example, and the content of the file is like this:
---
date: 2018-12-15T12:51:28Z
tags:
- tech life
draft: false
parent: /2018/11/my-history-in-text-editors/
author:
name: roytang
anonymous: false
username: roytang
---
<p>I don't usually need the font resize, but there's Ctrl + and Ctrl - available I believe. I haven't used VS Code long enough to have an opinion on extensions yet, maybe a follow-up post later down the line.</p>
The parent param links it back to the original page. Then in the page footer template you can have something like this to retrieve the matching comments:
<h1>Comments</h1>
{{ $url := urls.Parse .Permalink }}
{{ $filtered := where .Site.Pages "Params.parent" $url.Path }}
{{ range $filtered }}
<div class="comment">
<a href="{{.Permalink}}">Comment by {{ .Params.author.name }} on {{.Date.Format "2006-01-02"}}</a>
{{.Content}}
</div>
{{ end }}
It mostly works in my local testing, just need to see how it does when I import a whole batch of comments from Disqus and WP.
I’m fairly new to Hugo so IDK if this is the most efficient way to do it. I’m also not sure if there’s a better way to get the path component of the url from the permalink for the matching. Any advice would be great!
Once this is set up, you can just make a service to accept new comments via POST (or email or whatever method) and generate the md files (maybe set as draft first or in a separate place if you want to review them first)
(Edit: IDK what I was thinking with my first pass where I used intersect over two query sets when just one would have worked. Removed it from above)