Skip to content

Commit 779f78a

Browse files
manNomi한만욱
andauthored
refactor : global - layout (#211)
* refactor : global_layout dynamic 적용했습니다 * refactor : layout.tsx 부분도 다이나믹 및 불필요한 코드들 제거했습니다" --------- Co-authored-by: 한만욱 <manwook-han@hanman-ug-ui-MacBookPro.local>
1 parent 3c33bd6 commit 779f78a

7 files changed

Lines changed: 32 additions & 59 deletions

File tree

src/app/layout.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1+
/* eslint-disable @next/next/no-css-tags */
12
import type { Metadata, Viewport } from "next";
3+
import dynamic from "next/dynamic";
24
import { Inter } from "next/font/google";
35
import localFont from "next/font/local";
46

57
import GlobalLayout from "@/components/layout/GlobalLayout";
68

7-
import "../styles/globals.css";
8-
99
import { AlertProvider } from "@/context/AlertContext";
10-
import AppleScriptLoader from "@/lib/ScriptLoader/AppleScriptLoader";
11-
import KakaoScriptLoader from "@/lib/ScriptLoader/KakaoScriptLoader";
1210
import QueryProvider from "@/lib/react-query/QueryProvider";
1311
import { GoogleAnalytics } from "@next/third-parties/google";
1412

@@ -29,6 +27,15 @@ const pretendard = localFont({
2927
variable: "--font-pretendard",
3028
});
3129

30+
const KakaoScriptLoader = dynamic(() => import("@/lib/ScriptLoader/KakaoScriptLoader"), {
31+
ssr: false,
32+
loading: () => null,
33+
});
34+
const AppleScriptLoader = dynamic(() => import("@/lib/ScriptLoader/AppleScriptLoader"), {
35+
ssr: false,
36+
loading: () => null,
37+
});
38+
3239
declare global {
3340
interface Window {
3441
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -46,6 +53,20 @@ export const viewport: Viewport = {
4653
const RootLayout = ({ children }: { children: React.ReactNode }) => (
4754
<AlertProvider>
4855
<html lang="ko">
56+
<head>
57+
<link rel="preload" href="/_next/static/css/globals.css" as="style" />
58+
<link
59+
rel="stylesheet"
60+
href="/_next/static/css/globals.css"
61+
media="print"
62+
onLoad={(e) => {
63+
(e.currentTarget as HTMLLinkElement).media = "all";
64+
}}
65+
/>
66+
<noscript>
67+
<link rel="stylesheet" href="/_next/static/css/globals.css" />
68+
</noscript>
69+
</head>
4970
<KakaoScriptLoader />
5071
<AppleScriptLoader />
5172
<GoogleAnalytics gaId="G-V1KLYZC1DS" />

src/components/layout/GlobalLayout/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import dynamic from "next/dynamic";
12
import React from "react";
23

3-
import BottomNavigation from "./ui/BottomNavigation";
4-
import RootModal from "./ui/RootModal";
4+
import ServerModal from "./ui/ServerModal";
5+
6+
const BottomNavigation = dynamic(() => import("./ui/BottomNavigation"), { ssr: false, loading: () => null });
7+
const ClientModal = dynamic(() => import("./ui/ClientModal"), { ssr: false, loading: () => null });
58

69
type LayoutProps = {
710
children: React.ReactNode;
@@ -12,7 +15,8 @@ const GlobalLayout = ({ children }: LayoutProps) => {
1215
<div className="mx-auto mb-14 w-full min-w-[360px] max-w-[600px] pt-14">
1316
{children}
1417
<BottomNavigation />
15-
<RootModal />
18+
<ClientModal />
19+
<ServerModal />
1620
</div>
1721
);
1822
};

src/components/layout/GlobalLayout/ui/RootModal/ui/ClientModal/index.tsx renamed to src/components/layout/GlobalLayout/ui/ClientModal/index.tsx

File renamed without changes.

src/components/layout/GlobalLayout/ui/RootModal/index.tsx

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/components/layout/GlobalLayout/ui/RootModal/ui/ServerModal/index.tsx renamed to src/components/layout/GlobalLayout/ui/ServerModal/index.tsx

File renamed without changes.

src/pages/api/keywords.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/pages/api/news.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)