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

49 lines
2.6 KiB
Plaintext

{% comment %}
Mobile Comment View: Renders a flat list of top-level comments for the current post.
Assumes JavaScript will handle the navigation to nested replies using fragment identifiers.
{% endcomment %}
{% assign post_comments = site.comments | where: "post", page.slug %}
{% assign top_level_comments = post_comments | where_exp: "item", "item.parent == nil or item.parent == ''" | sort: "date" %}
<div id="mobile-comments-list" class="space-y-4">
{% if top_level_comments.size > 0 %}
{% for comment in top_level_comments %}
{% assign direct_replies = site.comments | where: "parent", comment.slug %}
<div class="border-b border-gray-200 pb-3 mb-3" id="mobile-comment-{{ comment.slug }}">
<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" title="Back"><i class="fas fa-arrow-left"></i></a>
<small class="ml-2 text-xs text-primary"><a href="#" class="text-text-muted hover:underline">@{{ comment.author }}</a></small>
<small class="ml-2 text-xs text-primary">{{ 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> | <a href="#" class="ml-2 text-xs text-primary hover:underline">[-]</a></small>
</div>
<p class="text-sm mb-2">{{ comment.content | default: "Missing content" }}</p> {# Added default filter #}
<div class="text-right">
{% if direct_replies.size > 0 %}
<a href="#mobile-comment-thread-{{ comment.slug }}" class="view-replies text-xs text-primary hover:underline" data-comment-slug="{{ comment.slug }}"> {# Use data attribute for JS #}
View Replies ({{ direct_replies.size }}) <i class="fas fa-chevron-right text-xs"></i>
</a>
{% else %}
<span class="text-xs text-text-muted opacity-75">No Replies</span>
{% endif %}
</div>
</div>
{% endfor %}
{% else %}
<p class="text-sm text-text-muted">No comments yet.</p>
{% endif %}
</div>
{% comment %}
Placeholder for where JavaScript would load the replies for a selected comment.
This container could be populated by JS when a 'View Replies' link is clicked.
{% endcomment %}
<div id="mobile-comment-thread-view" class="hidden mt-4">
<button class="back-to-list text-primary mb-2 text-sm">
<i class="fas fa-chevron-left text-xs"></i> Back to Comments
</button>
<div id="mobile-comment-thread-content">
<!-- Parent comment and its replies will be loaded here by JavaScript -->
</div>
</div>