Skip to content

Commit 8f5d2ba

Browse files
vcz-Chanclaude
andcommitted
✨ 게시글 본문 이미지 줌 및 코드 복사 기능 추가
- 이미지 클릭 시 모달로 확대 - 코드 블록에 복사 버튼 통합 - 호버 시 시각적 피드백 추가 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 155f4d8 commit 8f5d2ba

1 file changed

Lines changed: 38 additions & 8 deletions

File tree

src/components/PostDetail/Body.tsx

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,47 @@
22

33
import Markdown from '@uiw/react-markdown-preview';
44
import rehypeHighlight from 'rehype-highlight';
5+
import { useState } from 'react';
6+
import ImageZoomModal from '@/components/Common/ImageZoomModal';
7+
import CodeBlock from '@/components/Common/CodeBlock';
58

69
export function PostDetailBody({ content }: { content: string }) {
10+
const [zoomedImage, setZoomedImage] = useState<{ src: string; alt: string } | null>(null);
11+
712
return (
8-
<div data-color-mode="light" className="prose prose-sm sm:prose-base max-w-none md:p-6 font-sans">
9-
<Markdown
10-
source={content}
11-
rehypePlugins={[[rehypeHighlight, { detect: true }]]}
12-
components={{
13-
img: (props) => <img {...props} style={{ maxWidth: '100%' }} />,
14-
}}
13+
<>
14+
<div data-color-mode="light" className="prose prose-sm sm:prose-base max-w-none md:p-6 font-sans">
15+
<Markdown
16+
source={content}
17+
rehypePlugins={[[rehypeHighlight, { detect: true }]]}
18+
components={{
19+
img: (props) => (
20+
<img
21+
{...props}
22+
style={{ maxWidth: '100%', cursor: 'zoom-in' }}
23+
onClick={() => setZoomedImage({
24+
src: typeof props.src === 'string' ? props.src : '',
25+
alt: props.alt || ''
26+
})}
27+
className="rounded-lg hover:opacity-90 transition-opacity"
28+
alt={props.alt || ''}
29+
/>
30+
),
31+
pre: (props) => (
32+
<CodeBlock className={props.className}>
33+
{props.children}
34+
</CodeBlock>
35+
),
36+
}}
37+
/>
38+
</div>
39+
40+
<ImageZoomModal
41+
isOpen={!!zoomedImage}
42+
onClose={() => setZoomedImage(null)}
43+
imageSrc={zoomedImage?.src || ''}
44+
imageAlt={zoomedImage?.alt}
1545
/>
16-
</div>
46+
</>
1747
);
1848
}

0 commit comments

Comments
 (0)