Repository navigation
Expand file tree
/
Copy pathshareThings.js
More file actions
42 lines (31 loc) · 1.74 KB
/
Copy pathshareThings.js
File metadata and controls
42 lines (31 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const postContainer = document.getElementById("post-container");
function createPost(authorName, profileImageUrl, title, content, imageUrl) {
const postDiv = document.createElement("div");
postDiv.className = "post";
const authorInfoDiv = document.createElement("div");
authorInfoDiv.className = "author-info";
const profileImage = document.createElement("img");
profileImage.src = profileImageUrl;
profileImage.alt = "프로필 사진";
profileImage.className = "profile-image";
const authorNameElement = document.createElement("p");
authorNameElement.textContent = `${authorName}`;
authorInfoDiv.appendChild(profileImage);
authorInfoDiv.appendChild(authorNameElement);
const postTitle = document.createElement("h2");
postTitle.textContent = title;
const postContent = document.createElement("p");
postContent.textContent = content;
const postImage = document.createElement("img");
postImage.src = imageUrl;
postImage.alt = "게시물 이미지";
postDiv.appendChild(authorInfoDiv);
postDiv.appendChild(postTitle);
postDiv.appendChild(postContent);
postDiv.appendChild(postImage);
postContainer.appendChild(postDiv);
}
// 예시 게시물 추가
createPost("관리자", "images/userImage.png", "나만의 뷰티템을 갖고싶다면?!", "Make Your Beauty를 이용해보세요! 당신의 아름다움을 책임집니다!", "images/image1.png");
createPost("토끼끼", "images/userImage2.png", "안녕하세요~ 처음 글 써봅니다!", "화알못이라서 많이 부족하지만 배워가겠습니다~", "images/img2.png");
createPost("코덕", "images/userImage3.png", "제 뷰티템 소개할게요!","루즈 디올 사틴 피니쉬 추천합니다!", "images/dior.png");