From d303b4cd961615c4a9b647db3e54678eedef57eb Mon Sep 17 00:00:00 2001 From: "Kerby Martino (aider)" Date: Fri, 2 May 2025 12:33:53 +0800 Subject: [PATCH] feat: implement mobile comment view with flat list and nested replies navigation --- _includes/mobile_comment.liquid | 145 +++++++++++++++++++++++++++++++- 1 file changed, 142 insertions(+), 3 deletions(-) diff --git a/_includes/mobile_comment.liquid b/_includes/mobile_comment.liquid index 0c851f6..d20a12d 100644 --- a/_includes/mobile_comment.liquid +++ b/_includes/mobile_comment.liquid @@ -1,8 +1,147 @@ {% 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 top_comments = site.comments | where: "parent", nil | sort: "date" %} +{% 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" %} -{% for comment in top_comments %} -{% endfor %} \ No newline at end of file +
+ {% if top_level_comments.size > 0 %} + {% for comment in top_level_comments %} + {% assign direct_replies = site.comments | where: "parent", comment.slug %} +
+
+
+ + {{ comment.upvotes }} + + + REPLY + + + {{ direct_replies.size }} + +
+ + {{ comment.author }} + {{ comment.date | date: "%d %b %Y" }} + +
+

{{ comment.content | default: "Missing content" }}

+
+ {% if direct_replies.size > 0 %} + + View Replies ({{ direct_replies.size }}) + + {% else %} + No Replies + {% endif %} +
+
+ {% endfor %} + {% else %} +

No comments yet.

+ {% endif %} +
+ +{% 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 %} + + + +