feat: Create user posts page to display posts by a specific user
This commit is contained in:
1 parent
307a696ff7
commit
e9c493707d
2 files changed
+69
No files matched your search
@@ -0,0 +1,61 @@
|
|||||||
|
<h3 class="mt-4 text-lg font-medium">{{ page.author }}'s submissions</h3>
|
||||||
|
|
||||||
|
{% comment %} Filter posts by the author specified in the page front matter {% endcomment %}
|
||||||
|
{% assign user_posts = site.posts | where: "author", page.author | sort: 'date' | reverse %}
|
||||||
|
|
||||||
|
<div class="mt-4">
|
||||||
|
{% if user_posts.size > 0 %}
|
||||||
|
<div class="post-list space-y-4">
|
||||||
|
{% for post in user_posts %}
|
||||||
|
<div class="post-item mb-4" data-type="{{ post.type | default: 'unknown' }}" data-date="{{ post.date | date_to_xmlschema }}" data-upvotes="{{ post.upvotes | default: 0 }}" data-comments="{{ post.comments_count | default: 0 }}">
|
||||||
|
<article class="flex flex-col md:flex-row items-start">
|
||||||
|
<div class="flex-1 text-left">
|
||||||
|
<div>
|
||||||
|
<!-- Icon and Post Title -->
|
||||||
|
<div class="flex items-center space-x-2 mb-0.5">
|
||||||
|
{% assign post_type = post.type | default: 'unknown' %}
|
||||||
|
{% if post_type == "frustration" %}
|
||||||
|
<img src="/assets/images/icon_frustrated.png" alt="Frustration" class="w-5 h-5 object-contain flex-shrink-0" title="Frustration">
|
||||||
|
{% elsif post_type == "weird" %}
|
||||||
|
<img src="/assets/images/icon_weird.png" alt="Weird" class="w-5 h-5 object-contain flex-shrink-0" title="Weird">
|
||||||
|
{% elsif post_type == "win" %}
|
||||||
|
<img src="/assets/images/icon_win.png" alt="Win" class="w-5 h-5 object-contain flex-shrink-0" title="Win">
|
||||||
|
{% endif %}
|
||||||
|
<p class="mt-0 mb-0">
|
||||||
|
<strong>
|
||||||
|
<a href="{{ post.url | relative_url }}" class="text-text-title font-bold text-md md:text-sm hover:underline">
|
||||||
|
{{ post.title }}
|
||||||
|
</a>
|
||||||
|
</strong>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 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 | default: 0 }}
|
||||||
|
</span>
|
||||||
|
<a href="{{ post.url | relative_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="{{ post.url | relative_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> {{ post.comments_count | default: 0 }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<small class="text-sm font-action">
|
||||||
|
<a href="/user/{{ post.author }}/" 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 %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<p class="text-text-muted">This user has no submissions yet.</p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
layout: simple
|
||||||
|
title: User Submissions
|
||||||
|
author: post_author_placeholder # Replace with actual author/username variable if needed
|
||||||
|
permalink: /user_posts/ # Consider making this dynamic, e.g., /user/:username/posts/
|
||||||
|
---
|
||||||
|
|
||||||
|
{% include user_posts.liquid %}
|
||||||
Reference in new issue
Block a user