Skip to content

Commit 3f381fe

Browse files
committed
update post
1 parent 2987c63 commit 3f381fe

File tree

2 files changed

+23
-34
lines changed

2 files changed

+23
-34
lines changed

components/code-block.tsx

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import React, { useState, useEffect, useMemo } from "react";
3+
import React, { useState, useEffect } from "react";
44
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
55
import {
66
oneDark,
@@ -25,15 +25,15 @@ export default function CodeBlock({
2525
const [isCopied, setIsCopied] = useState(false);
2626
const [isCollapsed, setIsCollapsed] = useState(false);
2727
const [mounted, setMounted] = useState(false);
28-
const { theme, resolvedTheme } = useTheme();
29-
28+
const { resolvedTheme } = useTheme();
29+
3030
// 서버/클라이언트 하이드레이션 불일치 방지
3131
useEffect(() => {
3232
setMounted(true);
3333
}, []);
34-
34+
3535
// 실제 사용할 테마 (마운트 전에는 기본값 사용)
36-
const isDark = mounted ? (resolvedTheme === 'dark') : false;
36+
const isDark = mounted ? resolvedTheme === "dark" : false;
3737

3838
const handleCopy = async () => {
3939
await navigator.clipboard.writeText(code);
@@ -151,17 +151,20 @@ export default function CodeBlock({
151151

152152
{/* 마운트 전까지는 로딩 상태 표시 */}
153153
{!mounted ? (
154-
<div
154+
<div
155155
className="p-4 bg-muted/30 text-muted-foreground font-mono text-xs space-y-2 animate-pulse"
156-
style={{ minHeight: '8rem' }}
156+
style={{ minHeight: "8rem" }}
157157
>
158-
{code.split('\n').slice(0, 8).map((_, idx) => (
159-
<div
160-
key={idx}
161-
className="h-4 bg-muted-foreground/20 rounded"
162-
style={{ width: `${Math.floor(Math.random() * 50) + 50}%` }}
163-
></div>
164-
))}
158+
{code
159+
.split("\n")
160+
.slice(0, 8)
161+
.map((_, idx) => (
162+
<div
163+
key={idx}
164+
className="h-4 bg-muted-foreground/20 rounded"
165+
style={{ width: `${Math.floor(Math.random() * 50) + 50}%` }}
166+
></div>
167+
))}
165168
</div>
166169
) : (
167170
<SyntaxHighlighter
@@ -177,8 +180,10 @@ export default function CodeBlock({
177180
overflowWrap: "anywhere", // 어디서든 줄바꿈 허용
178181
maxWidth: "100%",
179182
overflowX: "visible", // 좌우 스크롤 제거
180-
background: isDark ? 'rgba(30, 30, 30, 0.95)' : 'rgba(250, 250, 250, 0.95)',
181-
transition: 'background 0.3s ease'
183+
background: isDark
184+
? "rgba(30, 30, 30, 0.95)"
185+
: "rgba(250, 250, 250, 0.95)",
186+
transition: "background 0.3s ease",
182187
}}
183188
wrapLines={true}
184189
wrapLongLines={true}

components/theme-provider.tsx

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
11
"use client";
22

3-
import { useEffect, useState } from "react";
3+
import * as React from "react";
44
import { ThemeProvider as NextThemesProvider } from "next-themes";
55

66
export function ThemeProvider({
77
children,
88
...props
99
}: React.ComponentProps<typeof NextThemesProvider>) {
10-
// 마운트 상태 관리
11-
const [mounted, setMounted] = useState(false);
12-
13-
// 마운트 상태만 체크
14-
useEffect(() => {
15-
setMounted(true);
16-
}, []);
17-
18-
return (
19-
<NextThemesProvider
20-
{...props}
21-
attribute="class"
22-
enableSystem
23-
>
24-
{children}
25-
</NextThemesProvider>
26-
);
10+
return <NextThemesProvider {...props}>{children}</NextThemesProvider>;
2711
}

0 commit comments

Comments
 (0)