Skip to content

Commit dbb3445

Browse files
authored
feat/src => main
Feat/src
2 parents 044ab8f + 99d178a commit dbb3445

File tree

6 files changed

+62
-54
lines changed

6 files changed

+62
-54
lines changed

index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<link rel="stylesheet" href="/src/styles/main.css" />
99
<link rel="stylesheet" href="/src/styles/common.css" />
1010
<link rel="stylesheet" href="/src/styles/editor.css" />
11-
<link rel="icon" href="/src/img/notion.svg" type="image/x-icon">
11+
<link rel="icon" href="/src/img/notion.svg" type="image/x-icon" />
1212
</head>
1313
<body>
1414
<div class="app">
@@ -42,8 +42,7 @@ <h3 class="myPage">내 페이지</h3>
4242

4343
<!-- 편집기 영역 -->
4444
<main id="content"></main>
45-
</>
46-
45+
</div>
4746
<script type="module" src="/src/index.js"></script>
4847
</body>
4948
</html>

src/components/Sidebar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ function renderTree(documents, parentElement = sidebarTree, depth = 0) {
170170
parentUl.previousElementSibling?.querySelector(
171171
".toggle-btn",
172172
)
173-
if (toggleBtn) toggleBtn.textContent = ""
173+
if (toggleBtn) toggleBtn.style.transform = "rotate(90deg)"
174174
}
175175
}
176176
openDocument(newDoc.id)

src/img/menu.svg

Lines changed: 7 additions & 6 deletions
Loading

src/img/sidemenu.svg

Lines changed: 8 additions & 0 deletions
Loading

src/router.js

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,65 @@
1-
import { EditPage } from "./components/Editor.js";
1+
import { EditPage } from "./components/Editor.js"
22

3-
const $content = document.getElementById("content");
3+
const $content = document.getElementById("content")
44

55
// 라우팅 처리 함수
66
function matchRoute(path) {
7-
if (path === "/") return routes["/"];
8-
if (path === "/documents") return routes["/documents"];
7+
if (path === "/") return routes["/"]
8+
if (path === "/documents") return routes["/documents"]
99

10-
// 동적 경로: /documents/:id
11-
if (path.startsWith("/documents/")) {
12-
const id = path.split("/")[2]; // "123" 부분 추출
13-
return () => routes["/documents/:id"](id);
14-
}
10+
// 동적 경로: /documents/:id
11+
if (path.startsWith("/documents/")) {
12+
const id = path.split("/")[2] // "123" 부분 추출
13+
return () => routes["/documents/:id"](id)
14+
}
1515

16-
return routes["/404"];
16+
return routes["/404"]
1717
}
1818

1919
// 라우팅 테이블
2020
const routes = {
21-
"/": () => {
22-
$content.innerHTML = "";
23-
},
24-
"/documents": () => {
25-
$content.innerHTML = "<h1>문서 목록</h1>";
26-
// 예시: 목록을 클릭하면 특정 id 문서로 이동
27-
const link = document.createElement("a");
28-
link.href = "/documents/123";
29-
link.textContent = "문서 123 보기";
30-
link.addEventListener("click", (e) => {
31-
e.preventDefault();
32-
navigateTo("/documents/123");
33-
});
34-
$content.appendChild(link);
35-
},
36-
"/documents/:id": (id) => {
37-
$content.innerHTML = "";
38-
// id를 EditPage에 전달 (실제라면 API로 문서 로드)
39-
EditPage($content, id);
40-
},
41-
"/404": () => {
42-
$content.innerHTML = "<p>404 - 페이지를 찾을 수 없습니다.</p>";
43-
},
44-
};
21+
"/": () => {
22+
$content.innerHTML = ""
23+
},
24+
"/documents": () => {
25+
$content.innerHTML = "<h1>문서 목록</h1>"
26+
// 예시: 목록을 클릭하면 특정 id 문서로 이동
27+
const link = document.createElement("a")
28+
link.href = "/documents/123"
29+
link.textContent = "문서 123 보기"
30+
link.addEventListener("click", (e) => {
31+
e.preventDefault()
32+
navigateTo("/documents/123")
33+
})
34+
$content.appendChild(link)
35+
},
36+
"/documents/:id": (id) => {
37+
$content.innerHTML = ""
38+
// id를 EditPage에 전달 (실제라면 API로 문서 로드)
39+
EditPage($content, id)
40+
},
41+
"/404": () => {
42+
$content.innerHTML = "<p>404 - 페이지를 찾을 수 없습니다.</p>"
43+
},
44+
}
4545

4646
export function navigateTo(path) {
47-
history.pushState({ path }, "", path);
48-
loadContent(path);
47+
history.pushState({ path }, "", path)
48+
loadContent(path)
4949
}
5050

5151
export function loadContent(path) {
52-
const handler = matchRoute(path);
53-
handler();
52+
const handler = matchRoute(path)
53+
handler()
5454
}
5555

5656
// popstate
5757
window.addEventListener("popstate", (e) => {
58-
const path = e.state?.path || "/";
59-
loadContent(path);
60-
});
58+
const path = e.state?.path || "/"
59+
loadContent(path)
60+
})
6161

6262
// 첫 로딩
6363
window.addEventListener("DOMContentLoaded", () => {
64-
loadContent(location.pathname);
65-
});
64+
loadContent(location.pathname)
65+
})

src/styles/main.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/* 사이드바 오픈 버튼 */
88
.open-btn {
99
display: none;
10-
background: url(/src/img/menu.svg) no-repeat center/cover;
10+
background: url(/src/img/sidemenu.svg) no-repeat center/cover;
1111
width: 30px;
1212
height: 30px;
1313
margin: 10px;

0 commit comments

Comments
 (0)