Skip to content

Commit 628e4ef

Browse files
committed
Add link to username
1 parent 0dcd60d commit 628e4ef

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

src/components/post/PostCommentItem.tsx

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import useBoolean from '../../lib/hooks/useBoolean';
1010
import PostRepliesContainer from '../../containers/post/PostRepliesContainer';
1111
import PostEditComment from '../../containers/post/PostEditComment';
1212
import media from '../../lib/styles/media';
13+
import { Link } from 'react-router-dom';
1314

1415
const PostCommentItemBlock = styled.div`
1516
padding-top: 1.5rem;
@@ -49,9 +50,17 @@ const CommentHead = styled.div`
4950
${media.small} {
5051
font-size: 0.875rem;
5152
}
53+
a {
54+
color: inherit;
55+
text-decoration: none;
56+
&:hover {
57+
text-decoration: underline;
58+
color: ${palette.gray7};
59+
}
60+
}
5261
}
5362
.date {
54-
margin-top: 0.25rem;
63+
margin-top: 0.5rem;
5564
color: ${palette.gray6};
5665
font-size: 0.875rem;
5766
${media.small} {
@@ -140,17 +149,25 @@ const PostCommentItem: React.FC<PostCommentItemProps> = ({
140149
// hides comment where it is deleted and its every reply is also deleted
141150
if (deleted && replies_count === 0) return null;
142151

152+
const velogLink = `/@${user && user.username}`;
153+
143154
return (
144155
<PostCommentItemBlock className="comment">
145156
<CommentHead>
146157
<div className="profile">
147-
<img
148-
src={(user && user.profile.thumbnail) || userThumbnail}
149-
alt="comment-user-thumbnail"
150-
/>
158+
<Link to={velogLink}>
159+
<img
160+
src={(user && user.profile.thumbnail) || userThumbnail}
161+
alt="comment-user-thumbnail"
162+
/>
163+
</Link>
151164
<div className="comment-info">
152165
<div className="username">
153-
{user ? user.username : '알 수 없음'}
166+
{user ? (
167+
<Link to={velogLink}>{user.username}</Link>
168+
) : (
169+
'알 수 없음'
170+
)}
154171
</div>
155172
<div className="date">{formatDate(created_at)}</div>
156173
</div>

0 commit comments

Comments
 (0)