Files
project-behind-the-desk/_includes/comment.liquid
T

29 lines
1.2 KiB
Plaintext

{% comment %}
Comment template - displays a single comment and its nested replies
{% endcomment %}
<div class="px-0 text-sm">
<div class="mb-1">
<a href="#" class="text-text-muted no-underline text-sm leading-none inline-block pt-0.5 hover:text-link-hover">▲</a>
<small class="text-text-muted ml-2 text-sm">@{{ comment.author }}</small>
<small class="text-text-muted ml-2 text-sm">{{ comment.date | date: "%b %d, %Y" }} | <a href="#" class="ml-2 text-xs text-primary hover:underline">parent</a> | <a href="#" class="ml-2 text-xs text-primary hover:underline">next</a></small>
</div>
<div>
<p>{{ comment.content }}</p>
<small class="text-right underline text-xs cursor-pointer mt-1 inline-block">reply</small>
</div>
{% comment %}
Find and render any replies to this comment
We need to get the filename without extension to match the parent field
{% endcomment %}
{% assign comment_filename = comment.path | split: "/" | last | replace: ".md", "" %}
{% assign replies = site.comments | where: "parent", comment_filename | sort: "date" %}
{% for reply in replies %}
<div class="ml-2 mt-4 border-l-2 border-gray-200 pl-2 text-sm md:pl-4">
{% include comment.liquid comment=reply %}
</div>
{% endfor %}
</div>