diff --git a/_includes/comment.liquid b/_includes/comment.liquid index fb52757..560b9f4 100644 --- a/_includes/comment.liquid +++ b/_includes/comment.liquid @@ -1,5 +1,5 @@ {% comment %} - Flat iterative version - no recursion, just nested loops up to N levels + Supports up to 6 levels of nested comments (non-recursive) {% endcomment %} {% assign top_comments = site.comments | where: "parent", nil | sort: "date" %} @@ -7,24 +7,24 @@ {% for comment in top_comments %}
{{ comment.content }}
reply - {% assign replies = site.comments | where: "parent", comment.slug | sort: "date" %} - {% for reply in replies %} + {% assign replies1 = site.comments | where: "parent", comment.slug | sort: "date" %} + {% for reply1 in replies1 %}{{ reply.content }}
+{{ reply1.content }}
reply - {% assign replies2 = site.comments | where: "parent", reply.slug | sort: "date" %} + {% assign replies2 = site.comments | where: "parent", reply1.slug | sort: "date" %} {% for reply2 in replies2 %}{{ reply2.content }}
reply - {# Extend further levels here if needed #} + + {% assign replies3 = site.comments | where: "parent", reply2.slug | sort: "date" %} + {% for reply3 in replies3 %} +{{ reply3.content }}
+ reply + + {% assign replies4 = site.comments | where: "parent", reply3.slug | sort: "date" %} + {% for reply4 in replies4 %} +{{ reply4.content }}
+ reply + + {% assign replies5 = site.comments | where: "parent", reply4.slug | sort: "date" %} + {% for reply5 in replies5 %} +{{ reply5.content }}
+ reply +