diff --git a/client/components/app/Post/index.jsx b/client/components/app/Post/index.jsx index 66236ad..ccf6936 100644 --- a/client/components/app/Post/index.jsx +++ b/client/components/app/Post/index.jsx @@ -12,18 +12,24 @@ import MarkdownContent from '@/components/app/Markdown'; export default function Post({ post: initialPost, onDelete, onNewComment }) { const [post, setPost] = useState(initialPost); const isPostPage = usePathname().includes('/app/posts/'); - const [isExpanded, setIsExpanded] = useState(false); - const lines = post.content.split('\n'); - const isLong = lines.length > 5 || post.content.length > 200; - const content = - isLong && !isPostPage - ? isExpanded - ? post.content - : lines.slice(0, 5).join('\n') + const contentLines = post.content.split('\n'); + const contentLength = post.content.length; + const lineCount = contentLines.length; + + const isLong = lineCount > 5 || contentLength > 500; + + const truncatedContent = + lineCount > 5 + ? contentLines.slice(0, 5).join('\n') + '...' + : contentLength > 500 + ? post.content.substring(0, 500) + '...' : post.content; + const contentToShow = + isExpanded || isPostPage ? post.content : truncatedContent; + return (