Files
project-behind-the-desk/_layouts/post.liquid
T
Kerby Martino 285de9287b Add upvotes and comments count to single post metadata
Updated the single post metadata to include upvotes and comments count. Adjusted the layout template to correctly reference the new comments_count field from the page object.
2025-05-02 03:13:03 +08:00

65 lines
2.8 KiB
Plaintext

---
layout: default
---
<article class="flex">
<div class="mr-2">
<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>
</div>
<div class="flex-1 text-left">
<div>
<p class="mt-0 mb-1">
<strong><a href="#" class="text-text-title font-bold text-base hover:underline">{{ page.title }}</a></strong>
</p>
<div class="post-content mb-2">
{{ content }}
</div>
<div class="mt-2 mb-1 text-sm flex flex-col md:flex-row items-start md:items-center md:space-x-2">
<div class="flex items-start space-x-2 mb-2 md:mb-0">
<span class="bg-gray-200 text-gray-700 text-xs font-action px-4 py-2 rounded-full flex items-center">
<i class="fa-solid fa-arrow-up mr-1"></i> {{ page.upvotes }}
</span>
<span class="bg-gray-200 text-gray-700 text-xs font-action px-4 py-2 rounded-full flex items-center">
<i class="fas fa-reply mr-1"></i> REPLY
</span>
<span class="bg-gray-200 text-gray-700 text-xs font-action px-4 py-2 rounded-full flex items-center">
<i class="fas fa-comment mr-1"></i> {{ page.comments_count }}
</span>
</div>
<small class="text-sm font-action">
<a href="#" class="text-sm hover:underline">{{ page.author }}</a>
<span class="text-text-muted text-sm opacity-75">{{ page.date | date: "%d %b %Y" }}</span>
</small>
</div>
</div>
</div>
</article>
<div class="mt-8">
<form>
<div class="mb-4">
<label class="block font-medium text-sm mb-1" for="comment-body">Comment:</label>
<div>
<textarea class="w-full px-3 py-2 bg-bg-light border border-gray-300 rounded" id="comment-body" name="body" placeholder="Enter your comment" required></textarea>
</div>
</div>
<div>
<button class="px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark" type="submit">Add Comment</button>
</div>
</form>
<h3 class="mt-4 text-lg font-medium">Comments</h3>
<div class="mt-4">
{% assign top_level_comments = site.comments | where: "post", page.slug | where_exp: "item", "item.parent == nil" | sort: "date" %}
{% if top_level_comments.size > 0 %}
{% for comment in top_level_comments %}
{% include comment.liquid comment=comment %}
{% endfor %}
{% else %}
<p>No comments yet.</p>
{% endif %}
</div>
</div>