From 0c79da8d9516693416b9ce169dd30627af232932 Mon Sep 17 00:00:00 2001 From: Ricardo Date: Wed, 11 Feb 2026 09:21:38 +0100 Subject: [PATCH] feat: type-aware rendering for recent posts section and sidebar widget Port the blog page's rich post-type rendering into both the homepage recent-posts section and the sidebar widget. Likes, bookmarks, reposts, replies, and photos now show colored icons, target URLs, and content previews instead of generic "Untitled" cards. Co-Authored-By: Claude Opus 4.6 --- .../components/sections/recent-posts.njk | 211 +++++++++++++++++- _includes/components/widgets/recent-posts.njk | 81 ++++++- 2 files changed, 276 insertions(+), 16 deletions(-) diff --git a/_includes/components/sections/recent-posts.njk b/_includes/components/sections/recent-posts.njk index f4449a0..a0fbc58 100644 --- a/_includes/components/sections/recent-posts.njk +++ b/_includes/components/sections/recent-posts.njk @@ -1,6 +1,7 @@ {# Recent Posts Section - displays latest posts from any collection Rendered by homepage-builder when recent-posts section is configured + Supports type-aware rendering for likes, bookmarks, reposts, replies, photos #} {% set sectionConfig = section.config or {} %} @@ -15,22 +16,187 @@
{% for post in collections.posts | head(maxItems) %} -
-

- - {{ post.data.title or post.data.name or "Untitled" }} +
+ + {# Detect post type from frontmatter properties #} + {% set likedUrl = post.data.likeOf or post.data.like_of %} + {% set bookmarkedUrl = post.data.bookmarkOf or post.data.bookmark_of %} + {% set repostedUrl = post.data.repostOf or post.data.repost_of %} + {% set replyToUrl = post.data.inReplyTo or post.data.in_reply_to %} + {% set hasPhotos = post.data.photo and post.data.photo.length %} + + {% if likedUrl %} + {# ── Like card ── #} +
+
+ +
+
+
+ Liked + +
+

+ + {{ likedUrl }} + +

+ {% if post.templateContent %} +
+ {{ post.templateContent | safe }} +
+ {% endif %} + Permalink +
+
+ + {% elif bookmarkedUrl %} + {# ── Bookmark card ── #} +
+
+ +
+
+
+ Bookmarked + +
+ {% if post.data.title %} +

+ {{ post.data.title }} +

+ {% endif %} +

+ + {{ bookmarkedUrl }} + +

+ {% if post.templateContent %} +
+ {{ post.templateContent | safe }} +
+ {% endif %} + Permalink +
+
+ + {% elif repostedUrl %} + {# ── Repost card ── #} +
+
+ +
+
+
+ Reposted + +
+

+ + {{ repostedUrl }} + +

+ {% if post.templateContent %} +
+ {{ post.templateContent | safe }} +
+ {% endif %} + Permalink +
+
+ + {% elif replyToUrl %} + {# ── Reply card ── #} +
+
+ +
+
+
+ In reply to + +
+

+ + {{ replyToUrl }} + +

+ {% if post.templateContent %} +
+ {{ post.templateContent | safe }} +
+ {% endif %} + Permalink +
+
+ + {% elif hasPhotos %} + {# ── Photo card ── #} +
+
+ +
+
+
+ Photo + +
+ + {% if post.templateContent %} +
+ {{ post.templateContent | safe }} +
+ {% endif %} + Permalink +
+
+ + {% elif post.data.title %} + {# ── Article card ── #} +

+ + {{ post.data.title }}

- - {% if showSummary and post.data.summary %} + {% if showSummary and post.templateContent %}

- {{ post.data.summary }} + {{ post.templateContent | striptags | truncate(250) }}

{% endif %} -
-
+ + {% else %} + {# ── Note card ── #} +
+ + + + {% if post.data.postType %} + + {{ post.data.postType }} + + {% endif %} +
+ {% if post.templateContent %} +
+ {{ post.templateContent | safe }} +
+ {% endif %} + + Permalink + + {% endif %} +
{% endfor %}

diff --git a/_includes/components/widgets/recent-posts.njk b/_includes/components/widgets/recent-posts.njk index 88bef43..68dcb15 100644 --- a/_includes/components/widgets/recent-posts.njk +++ b/_includes/components/widgets/recent-posts.njk @@ -1,20 +1,89 @@ -{# Recent Posts Widget (for non-blog pages) #} +{# Recent Posts Widget (sidebar) - compact type-aware list #} {% if recentPosts and recentPosts.length %}

Recent Posts

-