Skip to content

Commit

Permalink
modified commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ch9968 committed Jun 22, 2024
1 parent c2c9061 commit 3f45464
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions week10/my-app/src/pages/List.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ const PostListItemContainer = styled.div`
gap: 1em;
padding: 20px;
`;
const formatDate = (datetime) => {
const date = new Date(datetime);
return date.toLocaleDateString();
};

const PostListItem = styled.div`
border: 1px solid #ccc;
Expand All @@ -24,9 +20,10 @@ const PostListItem = styled.div`
`;

const PostImage = styled.img`
max-width: 00px;
max-width: 100%;
height: auto;
border-radius: 5px;
margin: 0.5em 0;
`;

const PostTitle = styled.p`
Expand All @@ -51,6 +48,11 @@ const PostDate = styled.p`
margin: 0.5em 0;
`;

const formatDate = (datetime) => {
const date = new Date(datetime);
return date.toLocaleDateString();
};

const ListPage = ({ posts, setPosts }) => {
const navigate = useNavigate();

Expand All @@ -66,7 +68,18 @@ const ListPage = ({ posts, setPosts }) => {
<PostTitle>์ œ๋ชฉ: {post.title}</PostTitle>
<PostNickname>๋‹‰๋„ค์ž„: {post.nickname}</PostNickname>
<PostContent>๋‚ด์šฉ: {post.content}</PostContent>
{post.image && <PostImage src={post.image} alt={post.title} />}
{post.image ? (
<PostImage
src={post.image}
alt={post.title}
onError={(e) => {
e.target.src = "https://via.placeholder.com/150";
e.target.alt = "Image not available";
}}
/>
) : (
<p>์ด๋ฏธ์ง€๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.</p>
)}
<PostDate>{formatDate(post.createdDate)}</PostDate>
</PostListItem>
))}
Expand Down

0 comments on commit 3f45464

Please sign in to comment.