feat: Display user submissions and comments on profile page

This commit is contained in:
Kerby Martino authored and Kerby Martino (aider) committed 2025-05-04 01:54:33 +08:00
1 parent 8daf52faac
commit b64b0c6970
1 file changed
+68 -12
+68 -12
View File
@@ -43,23 +43,79 @@
</div>
<div id="tab-submissions" class="hidden [&:target]:block">
<p class="text-text-muted">User submissions will be listed here.</p>
<!-- Placeholder: Add Liquid logic to loop through user's submissions -->
{% assign user_submissions = site.posts | where: "author", page.username %}
<ul>
{% for post in user_submissions %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
<!-- Post List -->
<div class="post-list space-y-4">
{% for post in site.posts %}
<div class="mb-4">
<article class="flex flex-col md:flex-row items-start">
<div class="flex-1 text-left">
<div>
<!-- Post Title -->
<p class="mt-0 mb-0.5">
<strong>
<a href="{{ post.url }}" class="text-text-title font-bold text-md md:text-sm hover:underline">
{{ post.title }}
</a>
</strong>
</p>
<!-- Post Metadata -->
<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 cursor-pointer hover:bg-link-hover">
<i class="fa-solid fa-arrow-up mr-1"></i> {{ post.upvotes }}
</span>
<span class="bg-gray-200 text-gray-700 text-xs font-action px-4 py-2 rounded-full flex items-center cursor-pointer hover:bg-link-hover">
<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 cursor-pointer hover:bg-link-hover">
<i class="fas fa-comment mr-1"></i> {{ post.comments_count }}
</span>
</div>
<small class="text-sm font-action">
<a href="#" class="text-sm hover:underline">{{ post.author }}</a>
<span class="text-text-muted text-sm opacity-75">{{ post.date | date: "%d %b %Y" }}</span>
</small>
</div>
</div>
</div>
</article>
<hr class="border-border-light my-4">
</div>
{% endfor %}
</ul>
</div>
</div>
<div id="tab-comments" class="hidden [&:target]:block">
<p class="text-text-muted">User comments will be listed here.</p>
<!-- Placeholder: Add Liquid logic to loop through user's comments -->
{% assign user_comments = site.comments | where: "author", page.username %}
<ul>
{% for comment in user_comments %}
<li>{{ comment.content | truncatewords: 15 }} - <a href="{{ comment.post_url }}#comment-{{ comment.id }}">view</a></li>
{% assign top_comments = site.comments | sort: "date" %}
<div class="mt-4">
<div id="mobile-comments-list" class="space-y-4">
{% for comment in top_comments %}
<div class="border-b border-gray-200 pb-3 mb-3" id="mobile-comment-comment1">
<p class="text-sm mb-2">{{ comment.content }}
</p>
<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 cursor-pointer hover:bg-link-hover">
<i class="fa-solid fa-arrow-up mr-1"></i> {{ comment.upvotes }}
</span>
<span class="bg-gray-200 text-gray-700 text-xs font-action px-4 py-2 rounded-full flex items-center cursor-pointer hover:bg-link-hover">
<i class="fas fa-reply mr-1"></i> REPLY
</span>
<a href="/comments/{{ comment.slug }}" class="bg-gray-200 text-gray-700 text-xs font-action px-4 py-2 rounded-full flex items-center cursor-pointer hover:bg-link-hover">
<i class="fas fa-comment mr-1"></i> {{ comment.replies }}
</a>
</div>
<small class="text-sm font-action">
<a href="#" class="text-sm hover:underline">{{ comment.author }}</a>
<span class="text-text-muted text-sm opacity-75">{{ comment.date | date: "%d %b %Y" }}</span>
</small>
</div>
</div>
{% endfor %}
</ul>
</div>
</div>
</div>
<div id="tab-favorites" class="hidden [&:target]:block">
<p class="text-text-muted">User favorites will be listed here.</p>