Skip to content

Commit 3574af4

Browse files
committed
refactor: 폴더 구조 개선
1 parent 430ba76 commit 3574af4

File tree

22 files changed

+485
-465
lines changed

22 files changed

+485
-465
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"scripts": {
66
"build": "turbo build --filter=!./apps/storybook",
77
"dev": "turbo dev --filter=!./apps/storybook",
8+
"dev:storybook": "turbo run dev storybook --filter=notion-to-jsx --filter=storybook",
89
"storybook": "turbo run storybook",
910
"build-storybook": "turbo run build-storybook",
1011
"lint": "turbo lint --filter=!./apps/storybook",

packages/notion-to-jsx/src/components/Bookmark.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState, useEffect } from 'react';
22
import styled from 'styled-components';
3-
import { RichTextItem } from '../types';
4-
import { RichText } from './RichText';
3+
import { type RichTextItem } from '../types';
4+
import RichTexts from './RichTexts';
55

66
interface OpenGraphData {
77
title: string;
@@ -79,7 +79,7 @@ const fetchOpenGraphData = async (url: string): Promise<OpenGraphData> => {
7979
};
8080
};
8181

82-
export const Bookmark: React.FC<BookmarkProps> = ({ url, caption }) => {
82+
const Bookmark: React.FC<BookmarkProps> = ({ url, caption }) => {
8383
const [ogData, setOgData] = useState<OpenGraphData | null>(null);
8484
const [error, setError] = useState(false);
8585

@@ -115,11 +115,13 @@ export const Bookmark: React.FC<BookmarkProps> = ({ url, caption }) => {
115115
{ogData?.siteName && <SiteName>{ogData.siteName}</SiteName>}
116116
{caption && caption.length > 0 && (
117117
<Caption>
118-
<RichText richText={caption} />
118+
<RichTexts richTexts={caption} />
119119
</Caption>
120120
)}
121121
</Content>
122122
</Card>
123123
</a>
124124
);
125125
};
126+
127+
export default Bookmark;

packages/notion-to-jsx/src/components/Image.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState, useEffect } from 'react';
22
import styled from 'styled-components';
33
import { RichTextItem } from '../types';
4-
import { RichText } from './RichText';
4+
import RichTexts from './RichTexts';
55

66
export interface ImageProps {
77
src: string;
@@ -76,7 +76,7 @@ export const Image: React.FC<ImageProps> = ({
7676
</ImageContainer>
7777
{caption && caption.length > 0 && (
7878
<Caption>
79-
<RichText richText={caption} />
79+
<RichTexts richTexts={caption} />
8080
</Caption>
8181
)}
8282
</figure>
Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import React from 'react';
2-
import { RichText, RichTextProps } from './RichText';
2+
import RichText, { RichTextProps } from './RichTexts';
33
import { Image, ImageProps } from './Image';
4-
import { Bookmark, BookmarkProps } from './Bookmark';
4+
import Bookmark, { type BookmarkProps } from './Bookmark';
55
import { RichTextItem } from '../types';
66

7-
export const MemoizedRichText = React.memo<RichTextProps>(RichText, (prev, next) => {
8-
return JSON.stringify(prev.richText) === JSON.stringify(next.richText);
9-
});
7+
export const MemoizedRichText = React.memo<RichTextProps>(
8+
RichText,
9+
(prev, next) => {
10+
return JSON.stringify(prev.richTexts) === JSON.stringify(next.richTexts);
11+
}
12+
);
1013

1114
export const MemoizedImage = React.memo<ImageProps>(Image, (prev, next) => {
1215
return (
@@ -16,20 +19,24 @@ export const MemoizedImage = React.memo<ImageProps>(Image, (prev, next) => {
1619
);
1720
});
1821

19-
export const MemoizedBookmark = React.memo<BookmarkProps>(Bookmark, (prev, next) => {
20-
return (
21-
prev.url === next.url &&
22-
JSON.stringify(prev.caption) === JSON.stringify(next.caption)
23-
);
24-
});
22+
export const MemoizedBookmark = React.memo<BookmarkProps>(
23+
Bookmark,
24+
(prev, next) => {
25+
return (
26+
prev.url === next.url &&
27+
JSON.stringify(prev.caption) === JSON.stringify(next.caption)
28+
);
29+
}
30+
);
2531

2632
// 타입 가드 유틸리티
2733
export const isRichTextArray = (value: unknown): value is RichTextItem[] => {
2834
if (!Array.isArray(value)) return false;
29-
return value.every((item) =>
30-
typeof item === 'object' &&
31-
item !== null &&
32-
'type' in item &&
33-
item.type === 'text'
35+
return value.every(
36+
(item) =>
37+
typeof item === 'object' &&
38+
item !== null &&
39+
'type' in item &&
40+
item.type === 'text'
3441
);
3542
};

0 commit comments

Comments
 (0)