diff --git a/docs/approute.md b/docs/approute.md new file mode 100644 index 000000000..c327c0c04 --- /dev/null +++ b/docs/approute.md @@ -0,0 +1,232 @@ +# Next.js App Router의 라우트 그룹(Route Groups) 구현 분석 + +## 개요 + +Next.js의 App Router에서는 괄호로 묶인 디렉토리(`(with-base-layout)`, `(without-base-layout)`)를 라우트 그룹으로 처리하여 URL 경로에 영향을 주지 않으면서 서로 다른 레이아웃을 적용할 수 있게 합니다. 이 문서에서는 프로젝트에서 라우트 그룹이 어떻게 구현되고 사용되는지 분석합니다. + +## 라우트 그룹 구조 분석 + +### 1. 디렉토리 구조 + +프로젝트에서는 두 가지 주요 라우트 그룹이 사용되고 있습니다: + +``` +/apps/cs/app/ +├── (with-base-layout)/ +│ ├── banner/ +│ ├── bbs/ +│ ├── code/ +│ ├── contents/ +│ ├── dashboard/ +│ ├── ... +│ ├── layout.tsx +│ └── loading.tsx +├── (without-base-layout)/ +│ ├── user-survey-article/ +│ └── user-survey-result/ +└── layout.tsx +``` + +### 2. 라우트 그룹별 레이아웃 구현 + +#### 루트 레이아웃 (`/apps/cs/app/layout.tsx`) + +```tsx +import type { Metadata } from "next"; +import { App } from "@/app"; + +export const metadata: Metadata = { + title: "유역하수도 통합 정보플랫폼", +}; + +export default App; +``` + +#### App 컴포넌트 (`/apps/cs/src/app/index.tsx`) + +```tsx +import "./styles/base.css"; +import "./styles/components.css"; +import "@fontsource-variable/noto-sans-kr"; + +import { AppProvider } from "./providers"; +import { cookies } from "next/headers"; + +const App = async ({ children }: Readonly<{ children: React.ReactNode }>) => { + const theme = (await cookies()).get("site-theme-key"); + + return ( + +
++ {comment.cmntCn} +
+