Skip to content

Commit ba76040

Browse files
authored
Feat/write#19 (#125)
* [feat] 글쓰기 기능 * [feat] 포스트 작성 기능 * Feat/communityscroll#23 (#114) * [feat] 스크롤링구현 * [feat] 주소, api설정 * [feat] 커뮤니티 탭, 필터 패치로직 * [feat] lastLikeCount, lastCommentCount, 추가 * [fix] 코멘트 삭제수정 마이페이지에선 뗄수있게 myPage props 추가 * 옵셔널로 수정 * 오류 수정 * [feat] 글쓰기 기능 * 카테고리필수 * [feat] 포스트 무한스크롤 + 글쓰기기능 이미지추가 * [feat] 이미지 스와이퍼 * [feat] 프로필 쑤리 이미지 * [feat] 댓글 누르면 댓글 섹션으로 가기 * [feat] 좋아요기능(아직 좋아요받아오는건 못함 api필요) * [feat] 게시물 수정 * [feat] 글 수정 * [refactor] 코드 조금정리 * [feat] 작성자본인만 글수정삭제 * [feat]글 삭제기능 * [feat] 칵테일태그 * [fix]칵테일, 쉐어 기능 * 수 라우터, 비로그인처리 * 타입 수정 * 타입 수정 * 타입수정 * 타입수정 * 타입수정 * 오류수정 * 오류수정 * 오류수정 * 오류수정 * 오류수정 * 충돌해결 * 오류 수정 * 오류 수정 * 오류 수정
1 parent 4f91a4f commit ba76040

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1300
-303
lines changed

next.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { NextConfig } from 'next';
33
const nextConfig: NextConfig = {
44

55
images: {
6+
domains: ['team2-app-s3-bucket.s3.ap-northeast-2.amazonaws.com'],
67
remotePatterns: [
78
{
89
protocol: 'https',

package-lock.json

Lines changed: 21 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
"react": "19.1.0",
2828
"react-dom": "19.1.0",
2929
"react-hot-toast": "^2.6.0",
30-
"react-intersection-observer": "^9.16.0",
31-
"react-use": "^17.6.0"
30+
"react-use": "^17.6.0",
31+
"swiper": "^12.0.2",
32+
"react-intersection-observer": "^9.16.0"
3233
},
3334
"devDependencies": {
3435
"@eslint/eslintrc": "^3",

src.zip

-997 KB
Binary file not shown.

src/app/community/[id]/page.tsx

Lines changed: 43 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,48 @@
1-
'use client';
2-
3-
import { fetchPostById } from '@/domains/community/api/fetchPost';
4-
import DetailContent from '@/domains/community/detail/DetailContent';
5-
import DetailHeader from '@/domains/community/detail/DetailHeader';
6-
import DetailTitle from '@/domains/community/detail/DetailTitle';
7-
import DetailTabDesktop from '@/domains/community/detail/tab/DetailTabDesktop';
8-
import { Post } from '@/domains/community/types/post';
9-
import Comment from '@/domains/community/detail/Comment';
10-
import StarBg from '@/domains/shared/components/star-bg/StarBg';
11-
import { useParams } from 'next/navigation';
12-
import { useEffect, useState } from 'react';
13-
import DetailSkeleton from '@/domains/community/detail/DetailSkeleton';
1+
import { Metadata } from 'next';
2+
import { getApi } from '@/app/api/config/appConfig';
3+
import DetailPage from '@/domains/community/detail/DetailPage';
4+
5+
type RouteParams = { id: number };
6+
7+
export async function generateMetadata({
8+
params,
9+
}: {
10+
params: Promise<RouteParams>;
11+
}): Promise<Metadata> {
12+
const { id } = await params;
13+
const res = await fetch(`${getApi}/posts/${id}`, {
14+
cache: 'no-store',
15+
});
16+
const post = await res.json();
17+
console.log(post);
18+
return {
19+
title: post.title,
20+
description: post.content?.slice(0, 80),
21+
openGraph: {
22+
title: post.title,
23+
description: post.content?.slice(0, 80),
24+
url: `https://your-domain.com/community/${id}`,
25+
images: [
26+
{
27+
url: post.imageUrls?.[0],
28+
width: 800,
29+
height: 600,
30+
alt: post.title,
31+
},
32+
],
33+
type: 'article',
34+
},
35+
twitter: {
36+
card: 'summary_large_image',
37+
title: post.title,
38+
description: post.content?.slice(0, 80),
39+
images: [post.imageUrls?.[0]],
40+
},
41+
};
42+
}
1443

1544
function Page() {
16-
const params = useParams();
17-
const [postDetail, setPostDetail] = useState<Post | null>(null);
18-
const [isLoading, setIsLoading] = useState(false);
19-
20-
useEffect(() => {
21-
const postId = params.id;
22-
const fetchData = async () => {
23-
setIsLoading(true);
24-
const data = await fetchPostById(postId);
25-
if (!data) return;
26-
27-
setPostDetail(data);
28-
setIsLoading(false);
29-
};
30-
fetchData();
31-
}, [params.id, setPostDetail]);
32-
33-
if (isLoading) return <DetailSkeleton />;
34-
if (!postDetail) return null;
35-
36-
const {
37-
categoryName,
38-
title,
39-
userNickName,
40-
createdAt,
41-
viewCount,
42-
postId,
43-
tags,
44-
content,
45-
likeCount,
46-
commentCount,
47-
} = postDetail;
48-
49-
return (
50-
<div className="w-full relative">
51-
<StarBg className="w-full h-32 absolute"></StarBg>
52-
<article className="page-layout max-w-824 z-5">
53-
<DetailHeader categoryName={categoryName} />
54-
<DetailTitle title={title} userNickname={userNickName} />
55-
<DetailContent
56-
content={content}
57-
createdAt={createdAt}
58-
viewCount={viewCount}
59-
postId={postId}
60-
tags={tags}
61-
likeCount={likeCount}
62-
commentCount={commentCount}
63-
/>
64-
<section className="mb-10">
65-
<Comment postId={postId} />
66-
</section>
67-
</article>
68-
<div className="hidden md:block">
69-
<DetailTabDesktop likeCount={likeCount} commentCount={commentCount} />
70-
</div>
71-
</div>
72-
);
45+
return <DetailPage />;
7346
}
7447

7548
export default Page;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use client';
2+
3+
import WriteSection from '@/domains/community/write/WriteSection';
4+
import StarBg from '@/domains/shared/components/star-bg/StarBg';
5+
import { useParams } from 'next/navigation';
6+
7+
function Page() {
8+
const params = useParams();
9+
10+
return (
11+
<div className="w-full mb-20 flex relative">
12+
<StarBg className="w-full h-32 absolute"></StarBg>
13+
<div className="page-layout max-w-824 flex-1 z-5">
14+
<WriteSection mode="edit" postId={params.postId} />
15+
</div>
16+
</div>
17+
);
18+
}
19+
20+
export default Page;

src/app/community/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function Page() {
1212
<div className="w-full">
1313
<PageHeader title="Community" description="칵테일에 관한 모든 이야기" />
1414
<div className="page-layout max-w-1024">
15-
<div className="mt-3 mb-10 flex flex-col gap-8 ">
15+
<div className="mt-3 mb-40 flex flex-col gap-8 ">
1616
<section aria-labelledby="community-heading">
1717
<h1 id="community-heading" className="sr-only">
1818
커뮤니티 페이지

src/app/community/write/page.tsx

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,15 @@
11
'use client';
22

3-
import Tag from '@/domains/community/components/tag/Tag';
4-
import Category from '@/domains/community/write/Category';
5-
import TagModal from '@/domains/community/write/cocktail-tag/TagModal';
6-
import CompleteBtn from '@/domains/community/write/CompleteBtn';
7-
import FormTitle from '@/domains/community/write/FormTitle';
8-
import ImageSection from '@/domains/community/write/image-upload/ImageSection';
9-
import WriteForm from '@/domains/community/write/WriteForm';
3+
import WriteSection from '@/domains/community/write/WriteSection';
104
import StarBg from '@/domains/shared/components/star-bg/StarBg';
11-
import { useState } from 'react';
125

136
function Page() {
14-
const [isOpen, setIsOpen] = useState(false);
15-
167
return (
178
<div className="w-full mb-20 flex relative">
189
<StarBg className="w-full h-32 absolute"></StarBg>
1910
<div className="page-layout max-w-824 flex-1 z-5">
20-
<CompleteBtn />
21-
<section>
22-
<FormTitle />
23-
<Category />
24-
<WriteForm />
25-
</section>
26-
<ImageSection />
27-
<section className="mt-8">
28-
<Tag use="write" onClick={() => setIsOpen(true)} />
29-
</section>
11+
<WriteSection mode="create" />
3012
</div>
31-
{isOpen && <TagModal isOpen={isOpen} setIsOpen={setIsOpen} />}
3213
</div>
3314
);
3415
}

src/app/layout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import Header from '@/shared/components/header/Header';
55
import FooterWrapper from '@/shared/components/footer/FooterWrapper';
66
import ScrollTopBtnWrapper from '@/shared/components/scroll-top/ScrollTopBtnWrapper';
77
import KaKaoScript from './api/kakao/KaKaoScript';
8+
import 'swiper/css';
9+
import 'swiper/css/navigation';
10+
import 'swiper/css/pagination';
811
import Provider from '@/shared/api/Provider';
912
import ClientInitHook from '@/domains/login/components/ClientInitHook';
1013

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { getApi } from '@/app/api/config/appConfig';
2+
3+
export const fetchCocktails = async () => {
4+
try {
5+
const res = await fetch(`${getApi}/cocktails`);
6+
if (!res.ok) throw new Error('칵테일 데이터 불러오기 실패');
7+
const data = await res.json();
8+
return data.data;
9+
} catch (error) {
10+
console.error(error);
11+
}
12+
};

0 commit comments

Comments
 (0)