Feat: Implement listing of user favorites in user profile

This commit is contained in:
Kerby Martino (aider) committed 2025-05-04 01:54:42 +08:00
1 parent b64b0c6970
commit 648c8a46cc
1 file changed
+70 -7
+70 -7
View File
@@ -118,16 +118,79 @@
</div>
</div>
<div id="tab-favorites" class="hidden [&:target]:block">
<p class="text-text-muted">User favorites will be listed here.</p>
<!-- Placeholder: Add Liquid logic to loop through user's favorites -->
{% if page.favorites %}
<ul>
{% if page.favorites and page.favorites.size > 0 %}
<div class="favorites-list space-y-4">
{% for favorite in page.favorites %}
<li><a href="{{ favorite.url }}">{{ favorite.title }}</a></li>
{% if favorite.title %}
<!-- Render as Post -->
<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="{{ favorite.url }}" class="text-text-title font-bold text-md md:text-sm hover:underline">
{{ favorite.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> {{ favorite.upvotes | default: 0 }}
</span>
<!-- Assuming a generic 'reply' action or link -->
<a href="{{ favorite.url }}#comments" 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
</a>
<a href="{{ favorite.url }}#comments" 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> {{ favorite.comments_count | default: 0 }}
</a>
</div>
<small class="text-sm font-action">
<a href="/user/{{ favorite.author }}/" class="text-sm hover:underline">{{ favorite.author }}</a>
<span class="text-text-muted text-sm opacity-75">{{ favorite.date | date: "%d %b %Y" }}</span>
</small>
</div>
</div>
</div>
</article>
<hr class="border-border-light my-4">
</div>
{% else %}
<!-- Render as Comment -->
<div class="border-b border-gray-200 pb-3 mb-3">
<p class="text-sm mb-2">{{ favorite.content | markdownify | strip_html }}</p> <!-- Assuming content might be markdown -->
<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> {{ favorite.upvotes | default: 0 }}
</span>
<!-- Link to the comment or its parent post -->
<a href="{{ favorite.url }}" 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
</a>
<!-- Link to the comment itself or context -->
<a href="{{ favorite.url }}" 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-link mr-1"></i> VIEW
</a>
</div>
<small class="text-sm font-action">
<a href="/user/{{ favorite.author }}/" class="text-sm hover:underline">{{ favorite.author }}</a>
<span class="text-text-muted text-sm opacity-75">{{ favorite.date | date: "%d %b %Y" }}</span>
{% if favorite.post_title %}
<span class="text-text-muted text-sm opacity-75">on: <a href="{{ favorite.post_url }}" class="hover:underline">{{ favorite.post_title }}</a></span>
{% endif %}
</small>
</div>
</div>
{% endif %}
{% endfor %}
</ul>
</div>
{% else %}
<p>No favorites yet.</p>
<p class="text-text-muted">No favorites yet.</p>
{% endif %}
</div>
</div>