-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from biud436:app-router
feat: App Router 적용
- Loading branch information
Showing
73 changed files
with
551 additions
and
528 deletions.
There are no files selected for viewing
Binary file removed
BIN
-2.75 KB
.yarn/cache/@babel-helper-annotate-as-pure-npm-7.18.6-36e25293d8-88ccd15ced.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-18.6 KB
.yarn/cache/babel-plugin-styled-components-npm-2.0.7-543710bd48-80b06b10db.zip
Binary file not shown.
Binary file removed
BIN
-1.67 KB
.yarn/cache/babel-plugin-syntax-jsx-npm-6.18.0-fcf0a98a71-0c7ce5b81d.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains 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 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
File renamed without changes.
This file contains 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,10 +1,12 @@ | ||
'use client'; | ||
|
||
import React from 'react'; | ||
import { PostEditorContainer } from '@/containers/PostEditorContainer'; | ||
import { useRouter } from 'next/router'; | ||
import { useSearchParams } from 'next/navigation'; | ||
|
||
export default function Editor() { | ||
const router = useRouter(); | ||
const { mode } = router.query; | ||
const searchParams = useSearchParams(); | ||
const mode = searchParams?.get('mode'); | ||
|
||
return <PostEditorContainer editorMode={mode as string} />; | ||
} |
This file contains 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,3 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; |
This file contains 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,50 @@ | ||
'use client'; | ||
|
||
import React from 'react'; | ||
// import type { Metadata } from 'next'; | ||
import StyledJsxRegistry from '../lib/registry'; | ||
import { RecoilRoot, RecoilEnv } from 'recoil'; | ||
// These styles apply to every route in the application | ||
import './globals.css'; | ||
import { Noto_Sans_KR } from 'next/font/google'; | ||
import { GlobalStyle } from '@/styles/global-styles'; | ||
import { CssBaseline, ThemeProvider } from '@mui/material'; | ||
import { RootProvider } from '@/blog/components/common/RootProvider'; | ||
import { ToastContainer } from 'react-toastify'; | ||
import { rootStore } from '@/store'; | ||
|
||
// export const metadata: Metadata = { | ||
// title: 'Create Next App', | ||
// description: 'Generated by create next app', | ||
// }; | ||
|
||
const notoSansKR = Noto_Sans_KR({ | ||
weight: '100', | ||
display: 'swap', | ||
subsets: ['latin'], | ||
}); | ||
|
||
RecoilEnv.RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED = false; | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return ( | ||
<html lang="en" className={notoSansKR.className}> | ||
<body> | ||
<StyledJsxRegistry> | ||
<RecoilRoot> | ||
<ThemeProvider theme={rootStore.themeStore.main}> | ||
<CssBaseline /> | ||
<GlobalStyle /> | ||
<RootProvider>{children}</RootProvider> | ||
</ThemeProvider> | ||
<ToastContainer /> | ||
</RecoilRoot> | ||
</StyledJsxRegistry> | ||
</body> | ||
</html> | ||
); | ||
} |
2 changes: 2 additions & 0 deletions
2
src/pages/manage/category/index.tsx → src/app/manage/category/page.tsx
This file contains 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 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 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 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,6 +1,8 @@ | ||
'use client'; | ||
|
||
import React from 'react'; | ||
import { NotFoundPage } from '@/containers/NotFoundPage'; | ||
|
||
export default function MyBlogError() { | ||
export default function NotFound() { | ||
return <NotFoundPage />; | ||
} |
This file contains 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,6 +1,11 @@ | ||
import React from 'react'; | ||
import { PostsPage } from '@/blog/pages/posts'; | ||
|
||
export const metadata = { | ||
title: '어진석의 블로그', | ||
description: '블로그', | ||
}; | ||
|
||
export default function MyMain() { | ||
return <PostsPage />; | ||
} |
This file contains 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 @@ | ||
'use client'; | ||
|
||
import React from 'react'; | ||
import { MainLayout } from '@/layouts/BlogMainLayout'; | ||
import { PostServiceProvider } from '@/services/PostService'; | ||
|
||
interface PostLayoutProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
export default function PostLayout({ children }: PostLayoutProps) { | ||
return ( | ||
<PostServiceProvider> | ||
<MainLayout name={''}>{children}</MainLayout> | ||
</PostServiceProvider> | ||
); | ||
} |
This file contains 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,151 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
/* eslint-disable @typescript-eslint/no-non-null-assertion */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import React from 'react'; | ||
import { cookies, headers } from 'next/headers'; | ||
import { API_URL, CacheControl } from '@/blog/api/request'; | ||
import { Post } from '@/models/Post'; | ||
import { ErrorBoundary } from '@/blog/components/error/ErrorBoundary'; | ||
import { PostPage } from '@/blog/pages/post'; | ||
import { Metadata, ResolvingMetadata } from 'next'; | ||
|
||
type Props = { | ||
params: { id: string }; | ||
searchParams: { [key: string]: string | string[] | undefined }; | ||
}; | ||
|
||
export async function generateMetadata( | ||
{ params, searchParams }: Props, | ||
parent: ResolvingMetadata, | ||
): Promise<Metadata> { | ||
// read route params | ||
const id = params.id; | ||
|
||
const headersList = headers(); | ||
const cookie = headersList.getSetCookie(); | ||
let post = {} as Post; | ||
let error: any | null = null; | ||
|
||
/** | ||
* Extract thumbnail from post.images | ||
* @param post | ||
*/ | ||
const extractThumbnail = (post: Post) => { | ||
if (post.images && post.images.length > 0) { | ||
post.thumbnail = post.images[0].path; | ||
} | ||
}; | ||
|
||
const requestDataUsingFetch = async () => { | ||
const hasCookie = !!cookie; | ||
|
||
try { | ||
const res = await fetch(API_URL + '/posts/' + id, { | ||
method: 'GET', | ||
credentials: 'include', | ||
// headers: { | ||
// ...CacheControl.NoCache, | ||
// ...(hasCookie ? { Cookie: cookie } : {}), | ||
// }, | ||
headers: { | ||
...CacheControl.NoCache, | ||
}, | ||
}); | ||
|
||
if (res.ok) { | ||
const data = await res.json(); | ||
post = data.data as Post; | ||
extractThumbnail(post); | ||
} | ||
} catch (e: any) { | ||
error = { | ||
message: 'Error occurred while fetching data', | ||
status: 500, | ||
}; | ||
} | ||
|
||
return post; | ||
}; | ||
|
||
const postEntity = await requestDataUsingFetch(); | ||
|
||
return { | ||
title: `${postEntity.title} - 어진석의 블로그`, | ||
description: postEntity.previewContent ?? '', | ||
openGraph: { | ||
images: [postEntity.thumbnail ?? ''], | ||
}, | ||
}; | ||
} | ||
|
||
async function getPost(id: string) { | ||
const headersList = headers(); | ||
const cookieStore = cookies(); | ||
const cookie = headersList.getSetCookie(); | ||
let post = {} as Post; | ||
let error: any | null = null; | ||
|
||
/** | ||
* Extract thumbnail from post.images | ||
* @param post | ||
*/ | ||
const extractThumbnail = (post: Post) => { | ||
if (post.images && post.images.length > 0) { | ||
post.thumbnail = post.images[0].path; | ||
} | ||
}; | ||
|
||
const requestDataUsingFetch = async () => { | ||
const hasCookie = !!cookie; | ||
|
||
try { | ||
const res = await fetch(API_URL + '/posts/' + id, { | ||
method: 'GET', | ||
credentials: 'include', | ||
// headers: { | ||
// ...CacheControl.NoCache, | ||
// ...(hasCookie ? { Cookie: cookie } : {}), | ||
// }, | ||
headers: { | ||
...CacheControl.NoCache, | ||
}, | ||
}); | ||
|
||
if (res.ok) { | ||
const data = await res.json(); | ||
post = data.data as Post; | ||
extractThumbnail(post); | ||
} | ||
} catch (e: any) { | ||
error = { | ||
message: 'Error occurred while fetching data', | ||
status: 500, | ||
}; | ||
} | ||
}; | ||
|
||
await requestDataUsingFetch(); | ||
|
||
return { | ||
post, | ||
error, | ||
}; | ||
} | ||
|
||
export default async function PostsPage({ params }: Props) { | ||
const { post, error } = await getPost(params.id); | ||
|
||
if (error) { | ||
return <div>{error}</div>; | ||
} | ||
|
||
return ( | ||
<PostPage | ||
{...{ | ||
post: post, | ||
id: String(post.id), | ||
error: error!, | ||
}} | ||
/> | ||
); | ||
} |
This file contains 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,19 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
'use client'; | ||
|
||
import SecretPostWrapper from '@/blog/components/post/SecretPostWrapper2'; | ||
import React from 'react'; | ||
|
||
export interface SecretPostProps { | ||
id: number; | ||
} | ||
|
||
export default function SecretPost({ | ||
params, | ||
}: { | ||
params: { | ||
id: string; | ||
}; | ||
}) { | ||
return <SecretPostWrapper id={Number(params.id)} />; | ||
} |
This file contains 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.