From ac0b093c265c298f273a91b979893b7683634281 Mon Sep 17 00:00:00 2001 From: "Kerby Martino (aider)" Date: Sun, 4 May 2025 02:19:49 +0800 Subject: [PATCH] fix: Render comments in "Favorites" tab with correct post links --- _includes/user_profile.liquid | 56 ++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/_includes/user_profile.liquid b/_includes/user_profile.liquid index 9af6934..88ed69f 100644 --- a/_includes/user_profile.liquid +++ b/_includes/user_profile.liquid @@ -165,32 +165,40 @@ {% else %} -
-

{{ item.content | markdownify | strip_html }}

-
-
- - {{ item.upvotes | default: 0 }} - - - - REPLY - - - - VIEW - -
- - {{ item.author }} - {{ item.date | date: "%d %b %Y" }} - {% assign parent_post = site.posts | where_exp: "post", "post.comments contains item" | first %} - {% if parent_post %} + {% comment %} Try to find the parent post using post_slug from comment front matter {% endcomment %} + {% assign parent_post = site.posts | where: "slug", item.post_slug | first %} + + {% if parent_post %} + {% comment %} Construct URL to the comment on the parent post's page {% endcomment %} + {% assign comment_anchor = '#comment-' | append: item.slug %} + {% assign comment_url = parent_post.url | append: comment_anchor %} +
+

{{ item.content | markdownify | strip_html }}

+
+
+ + {{ item.upvotes | default: 0 }} + + + + REPLY + + + + VIEW + +
+ + {{ item.author }} + {{ item.date | date: "%d %b %Y" }} on: {{ parent_post.title }} - {% endif %} - +
+
-
+ {% else %} + {% comment %} Optional: Render a fallback or error if parent post not found {% endcomment %} + + {% endif %} {% endif %} {% endfor %}