© 2020-present Sungjin Cho.
All Rights Reserved
App Router 방식의 특징들에 대해서 간략하게 정리해봄
/** Disable Vercel Data Cache */
export const fetchCache = 'force-no-store';
const result = await fetch(baseUrl + '/contents', {
cache: 'no-cache',
});
async function getBlog(slug: string): Promise<{
html: string;
frontmatter: Frontmatter;
content: string;
}> {
const result = await fetch(
`${process.env.API_BACKEND_BASE_URL}/content/${slug}`
);
return await result.json();
}
type Params = {
params: {
slug: string;
};
};
export default async function Page({ params: { slug } }: Params) {
_app.tsx
는 없어졌고, layout 컴포넌트로 대체됨export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
const themeFromCookie =
cookies().get('x-theme')?.value === Theme.DARK ? Theme.DARK : Theme.LIGHT;
return (
<html lang="en" className={themeFromCookie}>
<body className={inter.className}>
<ThemeProvider xTheme={themeFromCookie}>
<NavBar />
{children}
<Footer />
</ThemeProvider>
</body>
</html>
);
}
export default function Loading() {
return <div>Loading 중입니다!</div>;
}
'use client'; // 페이지 최상단에 써주면 됨