fix: Debug mobile comments and improve reply handling

This commit is contained in:
Kerby Martino (aider) committed 2025-05-02 12:05:53 +08:00
1 parent 4d119112f8
commit cf1499e0ec
1 file changed
+26 -9
+26 -9
View File
@@ -3,24 +3,38 @@
Assumes JavaScript will handle the navigation to nested replies using fragment identifiers. Assumes JavaScript will handle the navigation to nested replies using fragment identifiers.
{% endcomment %} {% endcomment %}
{% assign top_level_comments = site.comments | where: "post", page.slug | where_exp: "item", "item.parent == nil" | sort: "date" %} <!-- Debug: Page Slug: {{ page.slug }} -->
<!-- Debug: Total Comments in site.comments: {{ site.comments.size }} -->
{% assign post_comments = site.comments | where: "post", page.slug %}
<!-- Debug: Comments matching post '{{ page.slug }}': {{ post_comments.size }} -->
{% assign top_level_comments = post_comments | where_exp: "item", "item.parent == nil" | sort: "date" %}
<!-- Debug: Top-level comments for this post: {{ top_level_comments.size }} -->
<div id="mobile-comments-list" class="space-y-4"> <div id="mobile-comments-list" class="space-y-4">
{% if top_level_comments.size > 0 %} {% if top_level_comments.size > 0 %}
{% for comment in top_level_comments %} {% for comment in top_level_comments %}
<!-- Debug: Rendering comment by {{ comment.author | default: 'Unknown Author' }} with slug {{ comment.slug | default: 'no-slug' }} -->
{% assign direct_replies = site.comments | where: "parent", comment.slug %} {% assign direct_replies = site.comments | where: "parent", comment.slug %}
<div class="border-b border-gray-200 pb-3 mb-3" id="comment-{{ comment.slug }}"> <!-- Debug: Direct replies for {{ comment.slug }}: {{ direct_replies.size }} -->
<div class="border-b border-gray-200 pb-3 mb-3" id="mobile-comment-{{ comment.slug }}"> {# Changed ID prefix for clarity #}
<div class="flex justify-between items-center mb-1"> <div class="flex justify-between items-center mb-1">
<small class="text-xs text-primary"> <small class="text-xs text-primary">
<a href="#" class="text-text-muted hover:underline">@{{ comment.author }}</a> <a href="#" class="text-text-muted hover:underline">@{{ comment.author }}</a>
<span class="text-text-muted opacity-75 ml-2">{{ comment.date | date: "%b %d, %Y" }}</span> <span class="text-text-muted opacity-75 ml-2">{{ comment.date | date: "%b %d, %Y" }}</span>
</small> </small>
</div> </div>
<p class="text-sm mb-2">{{ comment.content }}</p> <p class="text-sm mb-2">{{ comment.content | default: "Missing content" }}</p> {# Added default filter #}
<div class="text-right"> <div class="text-right">
<a href="#comment-{{ comment.slug }}" class="view-replies text-xs text-primary hover:underline"> {% 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> View Replies ({{ direct_replies.size }}) <i class="fas fa-chevron-right text-xs"></i>
</a> </a>
{% else %}
<span class="text-xs text-text-muted opacity-75">No Replies</span>
{% endif %}
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
@@ -31,11 +45,14 @@
{% comment %} {% comment %}
Placeholder for where JavaScript would load the replies for a selected comment. Placeholder for where JavaScript would load the replies for a selected comment.
Example structure for a reply view (to be managed by JS): This container could be populated by JS when a 'View Replies' link is clicked.
{% endcomment %}
<div id="mobile-comment-thread-{{ some_comment_slug }}" class="hidden"> <div id="mobile-comment-thread-view" class="hidden mt-4">
<button class="back-to-list text-primary mb-2"> &lt; Back to Comments</button> <button class="back-to-list text-primary mb-2 text-sm">
<!-- Display parent comment --> <i class="fas fa-chevron-left text-xs"></i> Back to Comments
<!-- List replies for parent comment --> </button>
<div id="mobile-comment-thread-content">
<!-- Parent comment and its replies will be loaded here by JavaScript -->
</div> </div>
{% endcomment %} {% endcomment %}