-
Notifications
You must be signed in to change notification settings - Fork 1
[#171] 담당 페이지 메타데이터 작업 #181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
94cbb4a
refactor : 게시글 수정 디자인 수정
junye0l 2ad9003
refactor : 스타일 수정 및 가독성 개선
junye0l 3069b93
refactor : 계정 설정 페이지 디자인 수정
junye0l 7b2b27a
refactor : 토스트 컴포넌트 아웃라인 속성 제거
junye0l 6ee5e0e
fix : 마진 병합으로 인한 레이아웃 시프트 버그 해결
junye0l f54fa34
feat : 팀 참여 페이지 메타데이터 작업
junye0l 0775ec9
feat : 팀 생성 페이지 메타데이터 작업
junye0l 03dc067
feat : 계정 설정 페이지 메타데이터 작업
junye0l 8d81680
Merge branch 'develop' into feat/metadata-setting
junye0l d274260
feat : 자유게시판 페이지 메타데이터 작업
junye0l 69682e0
feat : 자유게시판 상세 페이지 동적 메타데이터 작업
junye0l 5da67c5
feat : 자유게시판 게시글 작성 페이지 메타데이터 작업
junye0l 1795210
refactor : 자유게시판 동적 메타데이터 개선 작업
junye0l 1efcc50
refactor : 메타데이터 일부 수정
junye0l c87ddd4
design : 자유게시판 더보기 버튼 제거
junye0l 4b54af8
chore : 기존 스크롤 방지 로직으로 롤백
junye0l f2864eb
refactor : 쿠키 전달하는 로직 추가
junye0l 6d2d7b3
refactor : 토큰 없을시 로그인 페이지로 리다이렉트 연결
junye0l dc00106
Merge branch 'develop' into feat/metadata-setting
junye0l File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import instance from "@/utils/axios"; | ||
| import { Article } from "@/types/article"; | ||
|
|
||
| const getArticleDetail = async (articleId: number): Promise<Article | null> => { | ||
| try { | ||
| const response = await instance.get(`/articles/${articleId}`); | ||
|
|
||
| if (!response) throw new Error("데이터를 불러오지 못했습니다."); | ||
|
|
||
| return response.data; | ||
| } catch (error) { | ||
| console.error(error); | ||
| return null; | ||
| } | ||
| }; | ||
|
|
||
| export default getArticleDetail; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 25 additions & 1 deletion
26
src/app/boards/[articleId]/_components/article-detail-client.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/app/boards/[articleId]/edit/_components/article-edit-client.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| "use client"; | ||
|
|
||
| import { useEffect } from "react"; | ||
| import cn from "@/utils/clsx"; | ||
| import { useGetArticleDetail } from "@/hooks/api/articles/use-get-article-detail"; | ||
| import { ArticleEditSkeleton } from "@/components"; | ||
| import ArticleEditContents from "./article-edit-contents/article-edit-contents"; | ||
| import { notFound } from "next/navigation"; | ||
| import { Article } from "@/types/article"; | ||
|
|
||
| interface ArticleEditClientProps { | ||
| articleId: number; | ||
| initialData?: Article | null; | ||
| } | ||
|
|
||
| export default function ArticleEditClient({ | ||
| articleId, | ||
| initialData, | ||
| }: ArticleEditClientProps) { | ||
| const { data, isPending } = useGetArticleDetail(articleId); | ||
|
|
||
| useEffect(() => { | ||
| if (initialData?.title) { | ||
| document.title = `${initialData.title} 수정`; | ||
| } | ||
| }, [initialData]); | ||
|
|
||
| if (initialData && isPending) { | ||
| return ( | ||
| <div | ||
| className={cn( | ||
| "mx-auto mt-[36px] w-full max-w-[343px] rounded-[20px] bg-white", | ||
| "tablet:mt-[117px] tablet:max-w-[620px]", | ||
| "pc:mt-[100px] pc:max-w-[900px]" | ||
| )} | ||
| > | ||
| <ArticleEditContents article={initialData} /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| if (isPending) return <ArticleEditSkeleton />; | ||
|
|
||
| if (!data?.article) { | ||
| notFound(); | ||
| } | ||
|
|
||
| return ( | ||
| <div | ||
| className={cn( | ||
| "mx-auto mt-[36px] w-full max-w-[343px] rounded-[20px] bg-white", | ||
| "tablet:mt-[117px] tablet:max-w-[620px]", | ||
| "pc:mt-[100px] pc:max-w-[900px]" | ||
| )} | ||
| > | ||
| <ArticleEditContents article={data.article} /> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,51 @@ | ||
| "use client"; | ||
| import type { Metadata } from "next"; | ||
| import ArticleEditClient from "./_components/article-edit-client"; | ||
| import getArticleDetail from "@/api/articles/get-article-detail"; | ||
|
|
||
| import { useParams } from "next/navigation"; | ||
| import { useGetArticleDetail } from "@/hooks/api/articles/use-get-article-detail"; | ||
| import { ArticleEditSkeleton } from "@/components"; | ||
| import ArticleEditContents from "./_components/article-edit-contents/article-edit-contents"; | ||
| import { notFound } from "next/navigation"; | ||
| interface PageProps { | ||
| params: Promise<{ articleId: string }>; | ||
| } | ||
|
|
||
| export default function EditPage() { | ||
| const params = useParams(); | ||
| const articleId = params.articleId; | ||
| export async function generateMetadata({ | ||
| params, | ||
| }: PageProps): Promise<Metadata> { | ||
| const { articleId } = await params; | ||
| const article = await getArticleDetail(Number(articleId)); | ||
|
|
||
| const { data, isPending } = useGetArticleDetail(Number(articleId)); | ||
| if (!article) { | ||
| return { | ||
| title: "게시글 수정", | ||
| description: "Coworkers 자유게시판 게시글 수정", | ||
| }; | ||
| } | ||
|
|
||
| if (isPending) return <ArticleEditSkeleton />; | ||
| return { | ||
| title: `${article.title} 수정`, | ||
| description: "Coworkers 자유게시판 게시글 수정", | ||
| openGraph: { | ||
| title: `${article.title} 수정 | Coworkers`, | ||
| description: "Coworkers 자유게시판 게시글 수정", | ||
| type: "website", | ||
| url: `https://coworkes.com/boards/${articleId}/edit`, | ||
| locale: "ko_KR", | ||
| siteName: "Coworkers", | ||
| images: [ | ||
| { | ||
| url: "https://sprint-fe-project.s3.ap-northeast-2.amazonaws.com/Coworkers/user/2449/open_graph.jpg", | ||
| width: 1200, | ||
| height: 630, | ||
| alt: "Coworkers 게시글 수정", | ||
| }, | ||
| ], | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| if (!data?.article) { | ||
| notFound(); | ||
| } | ||
| export default async function EditPage({ params }: PageProps) { | ||
| const { articleId } = await params; | ||
| const article = await getArticleDetail(Number(articleId)); | ||
|
|
||
| return ( | ||
| <div className="mx-auto my-[36px] w-full max-w-[343px] rounded-[20px] bg-white tablet:mb-[137px] tablet:mt-[117px] tablet:max-w-[620px] pc:my-[100px] pc:max-w-[900px]"> | ||
| <ArticleEditContents article={data.article} /> | ||
| </div> | ||
| <ArticleEditClient articleId={Number(articleId)} initialData={article} /> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,51 @@ | ||
| import type { Metadata } from "next"; | ||
| import ArticleDetailClient from "./_components/article-detail-client"; | ||
| import getArticleDetail from "@/api/articles/get-article-detail"; | ||
|
|
||
| interface PageProps { | ||
| params: Promise<{ articleId: string }>; | ||
| } | ||
|
|
||
| export async function generateMetadata({ | ||
| params, | ||
| }: PageProps): Promise<Metadata> { | ||
| const { articleId } = await params; | ||
| const article = await getArticleDetail(Number(articleId)); | ||
|
|
||
| if (!article) { | ||
| return { | ||
| title: "게시글", | ||
| description: "Coworkers 자유게시판", | ||
| }; | ||
| } | ||
|
|
||
| return { | ||
| title: article.title, | ||
| description: article.content.slice(0, 160), | ||
| openGraph: { | ||
| title: `${article.title} | Coworkers`, | ||
| description: article.content.slice(0, 160), | ||
| type: "article", | ||
| url: `https://coworkes.com/boards/${articleId}`, | ||
| locale: "ko_KR", | ||
| siteName: "Coworkers", | ||
| images: [ | ||
| { | ||
| url: "https://sprint-fe-project.s3.ap-northeast-2.amazonaws.com/Coworkers/user/2449/open_graph.jpg", | ||
| width: 1200, | ||
| height: 630, | ||
| alt: "Coworkers 자유게시판", | ||
| }, | ||
| ], | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| export default async function Page({ params }: PageProps) { | ||
| const { articleId } = await params; | ||
| const article = await getArticleDetail(Number(articleId)); | ||
|
|
||
| return <ArticleDetailClient articleId={Number(articleId)} />; | ||
| return ( | ||
| <ArticleDetailClient articleId={Number(articleId)} initialData={article} /> | ||
| ); | ||
| } |
8 changes: 1 addition & 7 deletions
8
src/app/boards/_components/boards-best/boards-best-header/boards-best-header.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { Metadata } from "next"; | ||
| import { ReactNode } from "react"; | ||
|
|
||
| export const metadata: Metadata = { | ||
| title: "자유게시판", | ||
| description: "Coworkers 자유게시판에서 다양한 이야기를 나누세요", | ||
| openGraph: { | ||
| title: "자유게시판 | Coworkers", | ||
| description: "Coworkers 자유게시판에서 다양한 이야기를 나누세요", | ||
| type: "website", | ||
| url: "https://coworkes.com/boards", | ||
| locale: "ko_KR", | ||
| siteName: "Coworkers", | ||
| images: [ | ||
| { | ||
| url: "https://sprint-fe-project.s3.ap-northeast-2.amazonaws.com/Coworkers/user/2449/open_graph.jpg", | ||
| width: 1200, | ||
| height: 630, | ||
| alt: "Coworkers 자유게시판", | ||
| }, | ||
| ], | ||
| }, | ||
| }; | ||
|
|
||
| const Layout = ({ children }: { children: ReactNode }) => { | ||
| return <>{children}</>; | ||
| }; | ||
|
|
||
| export default Layout; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.