Skip to content

Commit 7241138

Browse files
authored
Posts Page (#29)
* chore: Hide incomplete pages * feat: basic Posts page setting * refactor: change folder structure like FSD * refactor: use constant value in url * refactor: use assets index for short import * refactor: separate fetch code in api.ts * chore: correct url typo * refactor: alias setting the absolute path "src/" = "@/" * feat: add sort posts button * feat: add sort posts button
1 parent b2e29b4 commit 7241138

35 files changed

+295
-80
lines changed

apps/front/src/App.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import { BrowserRouter, Routes, Route } from "react-router-dom";
2-
import { Main, Posts, Study, Visitor } from "./pages";
2+
import { MainPage, PostsPage, StudyPage, VisitorPage } from "@/pages";
33
import { NavigationBar } from "./widgets/NavigationBar";
44
import styled from "@emotion/styled";
55
import { colors } from "@toss/tds-colors";
6-
import { Footer } from "./widgets";
6+
import { Footer } from "@/widgets";
77

88
function App() {
99
return (
1010
<BrowserRouter>
1111
<NavigationBar />
1212
<Container>
1313
<Routes>
14-
<Route path="/" element={<Main />} />
15-
<Route path="/posts" element={<Posts />} />
16-
<Route path="/Study" element={<Study />} />
17-
<Route path="/Visitor" element={<Visitor />} />
14+
<Route path="/" element={<MainPage />} />
15+
<Route path="/posts" element={<PostsPage />} />
16+
<Route path="/Study" element={<StudyPage />} />
17+
<Route path="/Visitor" element={<VisitorPage />} />
1818
</Routes>
1919
</Container>
2020
<Footer />

apps/front/src/assets/index.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import boolock from "./boolock.png";
2+
import choi from "./choi.jpg";
3+
import dongnaebangnae from "./dongnaebangnae.jpg";
4+
import github from "./github.png";
5+
import heart from "./heart.webp";
6+
import inhachoi from "./inhachoi.png";
7+
import logo from "./logo.png";
8+
import mdn from "./mdn.png";
9+
import react from "./react.png";
10+
import velog from "./velog.jpg";
11+
12+
export {
13+
boolock,
14+
choi,
15+
dongnaebangnae,
16+
github,
17+
heart,
18+
inhachoi,
19+
logo,
20+
mdn,
21+
react,
22+
velog,
23+
};

apps/front/src/hooks/index.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

apps/front/src/pages/Main.tsx renamed to apps/front/src/pages/MainPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import styled from "@emotion/styled";
2-
import { Contribution, Introduce, PopularPosts, Projects } from "../widgets";
2+
import { Contribution, Introduce, PopularPosts, Projects } from "@/widgets";
33

4-
export function Main() {
4+
export function MainPage() {
55
return (
66
<Container>
77
<Introduce />

apps/front/src/pages/Posts.tsx

Lines changed: 0 additions & 5 deletions
This file was deleted.

apps/front/src/pages/PostsPage.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import styled from "@emotion/styled";
2+
import { AllPosts } from "@/widgets";
3+
4+
export function PostsPage() {
5+
return (
6+
<Container>
7+
<Header>All</Header>
8+
<AllPosts />
9+
</Container>
10+
);
11+
}
12+
13+
const Container = styled.div`
14+
width: 100%;
15+
max-width: 768px;
16+
padding: 50px 15px;
17+
18+
@media (max-width: 768px) {
19+
padding: 35px 15px;
20+
}
21+
22+
@media (max-width: 480px) {
23+
padding: 20px 15px;
24+
}
25+
`;
26+
27+
const Header = styled.header`
28+
display: flex;
29+
flex-direction: column;
30+
justify-content: center;
31+
align-items: center;
32+
gap: 10px;
33+
font-size: 2rem;
34+
35+
@media (max-width: 768px) {
36+
font-size: 1.5rem;
37+
}
38+
39+
@media (max-width: 480px) {
40+
font-size: 1rem;
41+
}
42+
`;

apps/front/src/pages/Study.tsx renamed to apps/front/src/pages/StudyPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export function Study() {
1+
export function StudyPage() {
22
return <div>Study 화면 개발 중...</div>;
33
}
44

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export function Visitor() {
1+
export function VisitorPage() {
22
return <div>Visitor 화면 개발 중...</div>;
33
}
4-

apps/front/src/pages/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { Main } from "./Main";
2-
export { Posts } from "./Posts";
3-
export { Study } from "./Study";
4-
export { Visitor } from "./Visitor";
1+
export { MainPage } from "./MainPage";
2+
export { PostsPage } from "./PostsPage";
3+
export { StudyPage } from "./StudyPage";
4+
export { VisitorPage } from "./VisitorPage";

apps/front/src/shared/api.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { PostType } from "@/shared/types";
2+
3+
export const fetchPosts = async (): Promise<PostType[]> => {
4+
const res = await fetch("/api/posts");
5+
6+
if (!res.ok) {
7+
throw new Error(`HTTP ${res.status}`);
8+
}
9+
10+
const data = await res.json();
11+
12+
return data.posts;
13+
};

0 commit comments

Comments
 (0)