From 3eaf3c5eaf49ae46bb68a97015ccb5edcfba8189 Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Sun, 1 Jun 2025 18:14:35 +0200 Subject: [PATCH] fix(post): title could display some markdown syntax --- src/components/post/post.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/post/post.tsx b/src/components/post/post.tsx index efdd9833..b693c6b0 100644 --- a/src/components/post/post.tsx +++ b/src/components/post/post.tsx @@ -160,8 +160,10 @@ const Post = ({ index, post = {} }: PostProps) => { const [upvoted, upvote] = useUpvote(post); const [downvoted, downvote] = useDownvote(post); const postScore = getPostScore(upvoteCount, downvoteCount, state); - const postTitle = (title?.length > 300 ? title?.slice(0, 300) + '...' : title) || (content?.length > 300 ? content?.slice(0, 300) + '...' : content); - const highlightedTitle = searchQuery ? highlightMatchedText(postTitle || '', searchQuery) : postTitle; + const postTitle = + (title?.length > 300 ? title?.slice(0, 300) + '...' : title) || + (content?.length > 300 ? content?.slice(0, 300) + '...' : content)?.replace(' ', ' ')?.replace('>', '')?.replace('<', '')?.trim(); + const displayedTitle = searchQuery ? highlightMatchedText(postTitle || '', searchQuery) : postTitle; const hasThumbnail = getHasThumbnail(commentMediaInfo, link); const hostname = getHostname(link); @@ -236,11 +238,11 @@ const Post = ({ index, post = {} }: PostProps) => {

{isInPostPageView && link ? ( - {highlightedTitle ?? '-'} + {displayedTitle ?? '-'} ) : ( - {highlightedTitle ?? '-'} + {displayedTitle ?? '-'} )} {flair && (