fix(post): title could display some markdown syntax

This commit is contained in:
Tom (plebeius.eth)
2025-06-01 18:14:35 +02:00
parent 415a56c32d
commit 3eaf3c5eaf

View File

@@ -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('&nbsp;', ' ')?.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) => {
<p className={styles.title}>
{isInPostPageView && link ? (
<a href={link} className={linkClass} target='_blank' rel='noopener noreferrer' onClick={handlePostClick}>
{highlightedTitle ?? '-'}
{displayedTitle ?? '-'}
</a>
) : (
<Link className={linkClass} to={cid ? `/p/${subplebbitAddress}/c/${cid}` : `/profile/${post?.index}`} onClick={handlePostClick}>
{highlightedTitle ?? '-'}
{displayedTitle ?? '-'}
</Link>
)}
{flair && (