Conversation under Details view?

I wanted to experiment with showing replies on my microblog but hidden under a <details> block, and only if there were replies to a post. Otherwise, I’d prefer the Details not to show at all. I thought putting the block within the {{ if .Site.Params.include_conversation }} conditional would do that, but it still shows on every post, even those without replies.

Hugo magicians, any ideas?

<div>
      {{ partial "comments.html" . }}

{{ if .Site.Params.include_conversation }}
<details>
	<summary><strong>The conversation continues...</strong></summary>
<script type="text/javascript" src="https://micro.blog/conversation.js?url={{ .Permalink }}"></script>
</details>
{{ end }}
</div>

.Site.Params.include_conversation is a parameter global to your site. I’m not sure what the .Page variable is that indicates if there are any replies.

I don’t think there’s a .Page variable with the replies count available, unfortunately. You could call the JSON API or Conversation.js from Hugo to figure it out, but that’s a bad idea™. It would result in long build times for your blog and stress the network unnecessarily. Also, if someone comments on a post after the blog has been built, the conversation won’t show until the next build.

As fetching the conversation already happens client side, I would do the <details> dance with JavaScript as well.

1 Like

Hmm. Sounds like an interesting javascript project to put on the back burner.

Thanks!