From 653ea0d5d21646b6a995b583532fe8214aa01657 Mon Sep 17 00:00:00 2001 From: Yeolyi Date: Sat, 10 Feb 2024 22:17:16 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20SunEditor=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EB=B9=8C=EB=93=9C=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/[locale]/community/news/create/page.tsx | 5 +-- app/[locale]/layout.tsx | 4 ++ components/editor/common/SunEditorWrapper.tsx | 40 ++++++++++--------- next.config.mjs | 9 ++++- 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/app/[locale]/community/news/create/page.tsx b/app/[locale]/community/news/create/page.tsx index 9d037ff77..287c41780 100644 --- a/app/[locale]/community/news/create/page.tsx +++ b/app/[locale]/community/news/create/page.tsx @@ -1,8 +1,5 @@ -'use client'; - -import { useRouter } from 'next/navigation'; - import { revalidateNewsTag } from '@/actions/newsActions'; +import { useRouter } from '@/navigation'; import { postNews } from '@/apis/news'; diff --git a/app/[locale]/layout.tsx b/app/[locale]/layout.tsx index 8e49038a4..0054ad47a 100644 --- a/app/[locale]/layout.tsx +++ b/app/[locale]/layout.tsx @@ -1,5 +1,6 @@ import { notFound } from 'next/navigation'; import { NextIntlClientProvider } from 'next-intl'; +import { unstable_setRequestLocale } from 'next-intl/server'; import { ReactNode } from 'react'; import { Toaster } from 'react-hot-toast'; @@ -31,6 +32,9 @@ export default async function RootLayout({ children: React.ReactNode; params: { locale: string }; }) { + // https://next-intl-docs.vercel.app/docs/getting-started/app-router#static-rendering + unstable_setRequestLocale(params.locale); + return ( diff --git a/components/editor/common/SunEditorWrapper.tsx b/components/editor/common/SunEditorWrapper.tsx index 2af8913fa..74b0d9b0f 100644 --- a/components/editor/common/SunEditorWrapper.tsx +++ b/components/editor/common/SunEditorWrapper.tsx @@ -1,10 +1,13 @@ 'use client'; -import { MutableRefObject, Suspense, lazy } from 'react'; +import { MutableRefObject, lazy } from 'react'; import { ko } from 'suneditor/src/lang/'; import SunEditorCore from 'suneditor/src/lib/core'; import plugins from 'suneditor/src/plugins'; +// TODO +// 정말 왜그러는지 모르겠는데 lazy + typeof window 조합으로만 빌드가 됨 +// 건들지 말..것.. const SunEditor = lazy(() => import('suneditor-react')); import './suneditor.css'; @@ -18,7 +21,7 @@ export default function SunEditorWrapper({ initialContent?: string; }) { return ( - }> + typeof window !== 'undefined' && ( (editorRef.current = x)} setDefaultStyle={`padding: 1rem;`} @@ -39,25 +42,26 @@ export default function SunEditorWrapper({ // imageUploadUrl: `${BASE_URL}/file/upload`, }} /> - + ) ); } -const SunEditorFallback = () => { - return ( -
-
-
-
-
-
-
-
-
-
-
- ); -}; +// Suspense 쓰도록 고칠 때까지 삭제 +// const SunEditorFallback = () => { +// return ( +//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+// ); +// }; // https://github.com/JiHong88/SunEditor/issues/199 export const isContentEmpty = (editor: SunEditorCore) => { diff --git a/next.config.mjs b/next.config.mjs index 0b56d9935..368427e2f 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -5,7 +5,14 @@ const withNextIntl = createNextIntlPlugin(); /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, - output: 'standalone', + output: 'standalone', + + // TODO: 아래 옵션 없이 빌드 + eslint: { + // Warning: This allows production builds to successfully complete even if + // your project has ESLint errors. + ignoreDuringBuilds: true, + }, webpack(config) { // Grab the existing rule that handles SVG imports