Fixing post comment rendering
This commit is contained in:
1 parent
838f410b4d
commit
67edb553c7
4 files changed
+47
-12
No files matched your search
+1
-1
@@ -53,4 +53,4 @@ collections:
|
|||||||
permalink: /:collection/:title/
|
permalink: /:collection/:title/
|
||||||
comments:
|
comments:
|
||||||
output: false
|
output: false
|
||||||
permalink: /:collection/:title/
|
sort_by: date
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
{% 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>
|
||||||
+16
-11
@@ -14,11 +14,13 @@ layout: default
|
|||||||
<!-- Post title header -->
|
<!-- Post title header -->
|
||||||
<div class="mt-0.5 mb-2 text-sm flex items-center">
|
<div class="mt-0.5 mb-2 text-sm flex items-center">
|
||||||
<small class="text-text-muted ml-2 text-sm hover:underline">@{{ page.author }}</small>
|
<small class="text-text-muted ml-2 text-sm hover:underline">@{{ page.author }}</small>
|
||||||
{% assign comment_count = site.comments | where: "post", page.slug | size %}
|
{% assign filename = page.path | split: "/" | last | replace: ".markdown", "" | replace: ".md", "" %}
|
||||||
{% if comment_count == 0 %}
|
{% if page.slug %}
|
||||||
{% assign filename = page.path | split: "/" | last | replace: ".md", "" %}
|
{% assign post_id = page.slug %}
|
||||||
{% assign comment_count = site.comments | where: "post", filename | size %}
|
{% else %}
|
||||||
|
{% assign post_id = filename %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% assign comment_count = site.comments | where: "post", post_id | size %}
|
||||||
<small class="text-text-muted ml-2 text-sm">{{ page.date | date: "%B %d, %Y" }} | <a href="#" class="ml-2 text-xs text-primary hover:underline">report</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">{{ comment_count }} comments</a></small>
|
<small class="text-text-muted ml-2 text-sm">{{ page.date | date: "%B %d, %Y" }} | <a href="#" class="ml-2 text-xs text-primary hover:underline">report</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">{{ comment_count }} comments</a></small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -45,14 +47,17 @@ layout: default
|
|||||||
<h3 class="mt-4 text-lg font-medium">Comments</h3>
|
<h3 class="mt-4 text-lg font-medium">Comments</h3>
|
||||||
|
|
||||||
<div class="mt-4">
|
<div class="mt-4">
|
||||||
{% assign comments = site.comments | where: "post", page.slug | where_exp: "item", "item.parent == nil" %}
|
{% assign filename = page.path | split: "/" | last | replace: ".markdown", "" | replace: ".md", "" %}
|
||||||
{% if comments.size == 0 %}
|
{% if page.slug %}
|
||||||
{% assign filename = page.path | split: "/" | last | replace: ".md", "" %}
|
{% assign post_id = page.slug %}
|
||||||
{% assign comments = site.comments | where: "post", filename | where_exp: "item", "item.parent == nil" %}
|
{% else %}
|
||||||
|
{% assign post_id = filename %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if comments.size > 0 %}
|
{% assign top_level_comments = site.comments | where: "post", post_id | where_exp: "item", "item.parent == nil" | sort: "date" %}
|
||||||
{% for comment in comments %}
|
|
||||||
{% include comment.liquid comment=comment level=0 %}
|
{% if top_level_comments.size > 0 %}
|
||||||
|
{% for comment in top_level_comments %}
|
||||||
|
{% include comment.liquid comment=comment %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>No comments yet.</p>
|
<p>No comments yet.</p>
|
||||||
|
|||||||
@@ -3,5 +3,7 @@ layout: post
|
|||||||
title: "[Ask] The saga of the disappearing ergonomic chair continues."
|
title: "[Ask] The saga of the disappearing ergonomic chair continues."
|
||||||
date: 2023-10-02 10:00:00 +0000
|
date: 2023-10-02 10:00:00 +0000
|
||||||
categories: ask
|
categories: ask
|
||||||
|
slug: 2023-10-02-ask-the-saga-of-the-disappearing-ergonomic-chair-continues
|
||||||
|
author: deskdetective
|
||||||
---
|
---
|
||||||
The saga of the disappearing ergonomic chair continues.
|
The saga of the disappearing ergonomic chair continues.
|
||||||
Reference in new issue
Block a user