Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
6f60bd9
[feat] basic setting
May 17, 2022
315e3b4
.
May 18, 2022
68bb6d0
[feat] 기본 구조 설정
May 18, 2022
d464f74
[chore] 구조 수정
May 18, 2022
d189afa
[feat] recoil
May 18, 2022
ee8875d
[test] ;;
May 18, 2022
8fa9b91
Merge pull request #1 from momu-front/siwonblue
siwonblue May 18, 2022
0024e92
[test] 새로운커밋
May 18, 2022
b82a63d
Merge pull request #2 from momu-front/siwonblue
siwonblue May 18, 2022
f188b66
new commit
chaaerim May 18, 2022
6f3927f
Merge pull request #4 from momu-front/chaaerim
chaaerim May 18, 2022
5c703cb
[feat] test
May 18, 2022
c4c8158
Merge pull request #5 from momu-front/siwonblue
siwonblue May 18, 2022
3810efe
feat : 상세페이지 구현, DetailContent 컴포넌트 추가
chaaerim May 18, 2022
0e214c4
Merge pull request #6 from momu-front/chaaerim
chaaerim May 18, 2022
82a1ca2
feat : handlePostDelete 오류 수정, EditContent 컴포넌트 생성
chaaerim May 19, 2022
8cad0d4
Merge pull request #7 from momu-front/chaaerim
chaaerim May 19, 2022
4d25de1
refactor : link에서post 객체도 같이 넘기도록 수정
chaaerim May 19, 2022
18ea3e9
Merge pull request #8 from momu-front/chaaerim
chaaerim May 19, 2022
ed82676
feat : EditContent 시도 중 . . . (도와줘)
chaaerim May 19, 2022
bd11d62
Merge pull request #9 from momu-front/chaaerim
chaaerim May 19, 2022
b086f24
[feat] 글쓰기 기능, json 데이터 구조 살짝 변경
May 19, 2022
326363f
Merge pull request #10 from momu-front/siwonblue
siwonblue May 19, 2022
67f68e4
[feat] 에딧 수정
May 19, 2022
07b8aec
Merge pull request #11 from momu-front/siwonblue
siwonblue May 19, 2022
073833d
[feat] 기능개발 끝 스타일링 필요
May 19, 2022
339f704
Merge pull request #12 from momu-front/siwonblue
siwonblue May 19, 2022
d349daf
[style] 디자인 추가
May 19, 2022
1478f4c
Merge pull request #13 from momu-front/siwonblue
siwonblue May 19, 2022
558297c
style : react-icons 추가
chaaerim May 20, 2022
2b49d1e
style : DetailContent 컴포넌트 스타일링
chaaerim May 20, 2022
8050581
style : input, textarea 스타일링
chaaerim May 20, 2022
6d9a2d2
style : a 태그기본 스타일 제거, 스타일 추가
chaaerim May 20, 2022
aea4f7a
Merge pull request #14 from momu-front/chaaerim
chaaerim May 20, 2022
1537ac5
[chore] resizing none & 공백 방지
May 20, 2022
f97f38a
Merge pull request #15 from momu-front/siwonblue
siwonblue May 20, 2022
5f17dae
style : white-space: pre-line으로 변경
chaaerim May 20, 2022
594cfd7
Merge pull request #16 from momu-front/chaaerim
chaaerim May 20, 2022
79e438d
chore : 타입에러 수정
chaaerim May 20, 2022
d0d810c
Merge pull request #17 from momu-front/chaaerim
chaaerim May 20, 2022
6ca5d35
[fix] 오류 수정
May 20, 2022
bdea559
[fix] 오류 수정
May 20, 2022
7734fee
Merge branch 'main' into siwonblue
siwonblue May 20, 2022
cf5da98
Merge pull request #18 from momu-front/siwonblue
siwonblue May 20, 2022
3620b9b
add favicon
May 20, 2022
8126bf1
Merge pull request #19 from momu-front/siwonblue
siwonblue May 20, 2022
09acb20
폴더구조 변경
May 20, 2022
2e07c3e
Merge pull request #20 from momu-front/siwonblue
siwonblue May 20, 2022
a64d5d7
[chore] alert 수정
May 21, 2022
e59c4fb
[feat] README.md
May 21, 2022
9892907
Merge pull request #21 from momu-front/siwonblue
siwonblue May 21, 2022
8754ab7
[fix] css ssr 버그 수정
Jun 1, 2022
18a666d
Merge pull request #22 from momu-front/siwonblue
siwonblue Jun 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"presets": [
"next/babel"
],
"plugins": [
[
"babel-plugin-styled-components",
{
"fileName": true,
"displayName": true,
"pure": true
}
]
]
}
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/prettier.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/react-blog-15th.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true
}
81 changes: 47 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,63 @@
# 6주차 미션: React-Blog 📄

# 서론
# 과제 제출

안녕하세요 🙌🏻 15기 프론트 파트장 **김주현**입니다.
---
모무 프론트 <br> 전시원 김채림

이번주에는 새 프로젝트인 **블로그** 만들기를 진행합니다. 이번 과제에서는 Next.js를 사용해 보며 SSR을 이해하고, 각 팀별로 미리 호흡을 맞춰 보는 좋은 기회가 될 것 같습니다.
### 목차

# 미션
> 1. 어떻게 구현했는가
> 2. css 서버사이드 렌더링 적용
> 3. pull request 내용

## 미션 목표
# 1. 어떻게 구현했는가

- Next.js 사용법을 공부해 봅니다.
- 성능 최적화를 위한 방법을 적용해 봅니다.
- Git을 이용한 협업 방식에 익숙해집니다.
### Landing

## 기한

- 2022년 5월 20일 금요일 **(기한 엄수!)**
- 주소창 '/' <br>랜딩페이지, 들어오게 되면 게시물을 나열 <br> 제목과 게시한 날짜(월,일)을 표시함 <br>

## 필수 요건

- 기본적인 CRUD를 구현합니다.
- 메인 페이지, 포스트 상세 페이지, 에디터 페이지로 구성합니다.
- 메인 페이지에서는 각 포스트들의 제목과 작성 날짜를 리스트 형태로 보여줍니다.
- 포스트 상세 페이지에서는 제목, 작성일, 본문의 내용을 표시합니다.
- 포스트를 수정할 때에는 기존에 작성된 내용을 에디터 페이지로 불러옵니다.
- 포스트 삭제 기능을 구현합니다.
- 성능 최적화를 위한 방법을 적용해 봅니다.
### POST (CREATE)

## 선택 사항
- 주소창 '/post' <br>
게시글을 작성하게 되면 제목과 본문내용을 담아서 recoil 이 보관<br>
게시글 id 도 recoil 에서 전역관리하여 새로운 게시글이 만들어질 때마다
+1 시켜서 관리

- 웹 폰트를 사용합니다.
- 카테고리 기능을 구현합니다.
- 그 외에 자유롭게 기능을 추가해 주세요!

## Key Question
### GET (READ)

- Next.js를 사용하는 이유
- SEO란?
- 성능 최적화를 위해 사용한 방법
- 전반적인 협업 과정
- 주소창 '/get/[id]' <br>
랜딩페이지에서 게시글을 누르면 게시글의 id 값을 주소창에 담아서 넘김<br>
동적라우팅을 통해 주소창 설계 <br>
해당 id 값을 /get/[id] 페이지에서 받은 다음 recoil 에 저장된 데이터를 가져옴<br>
posts 객체를 가져오면 그대로 게시글에 대한 데이터를 렌더링

### EDIT (UPDATE)

# 링크 및 참고자료
- 주소창 '/edit/[id]' <br>
랜딩페이지에서 게시글을 누르고 나면 게시글을 상세히 볼 수 있음.<br>
그곳에서 수정하기 버튼을 눌러 접근<br>
get 과 동일한 논리로 게시글 가져온 다음 렌더링<br>
차이점은 input 창의 value 로 이미 작성되어 있는 내용을 넣어 줘야 함.

### 페이지 없음 (DELETE)
- 주소창 없음 <br>
지우기 버튼을 누르면 해당 아이디에 맞는 게시물을 posts 배열에서 삭제

### 데이터 구조

```json
{
"posts": [
{
"id": "number",
"title": "string",
"contents": "string",
"date": "string"
}
]
}
```

- [Next.js Docs](https://nextjs.org/docs/getting-started)
- [React 개발이 이렇게 쉬웠나? (Feat. Next.js)](https://geonlee.tistory.com/229)
- [useCallback과 React.Memo를 이용한 렌더링 최적화](https://velog.io/@yejinh/useCallback%EA%B3%BC-React.Memo%EC%9D%84-%ED%86%B5%ED%95%9C-%EB%A0%8C%EB%8D%94%EB%A7%81-%EC%B5%9C%EC%A0%81%ED%99%94)
- [성능 최적화](https://ui.toast.com/fe-guide/ko_PERFORMANCE)
- [Git 협업 가이드](https://velog.io/@jinuku/Git-%ED%98%91%EC%97%85-%EA%B0%80%EC%9D%B4%EB%93%9C)
59 changes: 59 additions & 0 deletions components/Alist.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { postList } from '../store/recoil';
import { useRecoilValue } from 'recoil';
import styled from 'styled-components';
import Link from 'next/link';
import React from 'react';

const Alist = () => {
const posts = useRecoilValue(postList);
return (
<>
{posts?.map((post) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

주현씨 코드 스타일이랑 비슷하네요 반가워요

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 그런가요?? 신기하네요 ㅎㅎ

return (
<Wrapper key={post.id}>
<Link
href={{
pathname: `/get/${post.id}`,
query: {
currentPost: JSON.stringify(post),
},
}}
as={`/get/${post.id}`}
>
<LinkToPost>{post.title}</LinkToPost>
</Link>
<DateDiv>{post.date}</DateDiv>
</Wrapper>
);
})}
</>
);
};

const Wrapper = styled.div`
display: grid;
grid-template-columns: 8fr 2fr;
width: 90%;
padding: 0 1rem;
border: 1px solid black;
border-radius: 0.5rem;
margin: 10px auto 10px auto;
box-sizing: border-box;
word-break: break-all;
`;
const DateDiv = styled.div`
display: flex;
justify-content: center;
align-items: center;
color: #afaaaa;
`;

const LinkToPost = styled.a`
padding: 0.5rem;
display: flex;
text-decoration: none;
color: black;
font-size: 1.2rem;
font-weight: lighter;
`;
export default Alist;
92 changes: 92 additions & 0 deletions components/AppLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { FC } from 'react';
import styled from 'styled-components';
import Link from 'next/link';
import { useRouter } from 'next/router';
import { AiOutlineHome } from 'react-icons/ai';
import { HiOutlinePencil } from 'react-icons/hi';
import React from 'react';

type Props = {
children: React.ReactNode;
};

const AppLayout: FC<Props> = ({ children }) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fc는 꼭 써야 할까?
[Typescript] FunctionComponent (FC) 사용 줄이기
시간 날 때 읽어보면 재밌을 것 같아요~

const router = useRouter();
const pathname = router.pathname;

return (
<>
<Container>
<Navbar>
{pathname === '/' ? (
<>
<Link href="/">
<a>
<HomeBtn>
<AiOutlineHome size={16} />
Home
</HomeBtn>
</a>
</Link>
<Link href="/post">
<PostBtn>
<HiOutlinePencil size={16} />
Post
</PostBtn>
</Link>
</>
) : (
<>
<Link href="/">
<a>
<HomeBtn>
<AiOutlineHome size={16} />
Home
</HomeBtn>
</a>
</Link>
<Link href="/post">
<PostBtn post>
{' '}
<HiOutlinePencil size={16} />
Post
</PostBtn>
</Link>
</>
)}
</Navbar>
{children}
</Container>
</>
);
};

const Container = styled.div`
padding: 1rem;
overflow: scroll;
width: 500px;
height: 500px;
border-radius: 10px;
-webkit-box-shadow: 5px 5px 15px 0px #000000;
box-shadow: 5px 5px 15px 0px #000000;
`;
const Navbar = styled.div`
display: flex;
width: 90%;
margin: auto;
`;
const HomeBtn = styled.button`
padding-right: 1rem;
font-size: 20px;
border: none;
background: none;
`;

const PostBtn = styled.button<{ post?: boolean }>`
font-size: 20px;
border: none;
background: none;
color: ${(props) => (props.post ? 'grey' : 'black')};
`;

export default React.memo(AppLayout);
Loading