Skip to content

Commit ee9e69a

Browse files
committed
refactor: remove unused Vite config file, update TypeScript configurations, and add Children component for nested rendering
1 parent d06de8c commit ee9e69a

File tree

15 files changed

+84
-88
lines changed

15 files changed

+84
-88
lines changed

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "react-notion-blocks",
3-
"version": "1.1.6",
3+
"version": "1.1.8",
44
"type": "module",
55
"description": "A library for mapping Notion blocks to React components",
66
"main": "dist/index.js",
7-
"module": "dist/index.mjs",
7+
"module": "dist/index.js",
88
"exports": {
9-
"import": "./dist/index.mjs",
9+
"import": "./dist/index.js",
1010
"require": "./dist/index.js",
1111
"default": "./dist/index.mjs"
1212
},
@@ -36,8 +36,7 @@
3636
],
3737
"scripts": {
3838
"dev": "vite",
39-
"build": "tsc --build",
40-
"build:app": "tsc --build tsconfig.app.json",
39+
"build": "tsc -b && vite build",
4140
"lint": "eslint .",
4241
"preview": "vite preview",
4342
"prepublishOnly": "npm run build"
@@ -55,11 +54,11 @@
5554
}
5655
},
5756
"dependencies": {
58-
"@tailwindcss/vite": "^4.0.9",
5957
"prismjs": "^1.29.0"
6058
},
6159
"devDependencies": {
6260
"@eslint/js": "^9.21.0",
61+
"@tailwindcss/vite": "^4.0.9",
6362
"@types/node": "^22.13.5",
6463
"@types/prismjs": "^1.26.5",
6564
"@types/react": "^19.0.10",

src/components/Children.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { BaseBlock } from "@/types";
2+
import { Paragraph } from "./Paragraph";
3+
import { ParagraphBlock } from "@/types/paragraph.types";
4+
5+
interface ChildrenProps {
6+
children: BaseBlock[];
7+
className?: string
8+
}
9+
10+
export const Children = ({ children, className }: ChildrenProps) => {
11+
if (!Array.isArray(children) || children.length === 0) {
12+
return null;
13+
}
14+
15+
return (
16+
<div className={`ml-4 ${className}`}>
17+
{children.map((child) => {
18+
switch (child.type) {
19+
case "paragraph":
20+
return <Paragraph key={child.id} block={child as ParagraphBlock} />;
21+
default:
22+
return null;
23+
}
24+
})}
25+
</div>
26+
);
27+
};

src/components/Paragraph.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// src/modules/notion-blocks/components/Paragraph.tsx
22
import { ParagraphBlock } from "../types/paragraph.types";
3+
import { Children } from "./Children";
34
import { RichText } from "./RichText";
45

56
export const Paragraph = ({ block }: { block: ParagraphBlock }) => {
@@ -9,8 +10,11 @@ export const Paragraph = ({ block }: { block: ParagraphBlock }) => {
910
}
1011

1112
return (
12-
<p className="text-base leading-relaxed mb-4">
13-
<RichText richText={block.paragraph.rich_text} />
14-
</p>
13+
<div>
14+
<p className="text-base leading-relaxed mb-4">
15+
<RichText richText={block.paragraph.rich_text} />
16+
</p>
17+
{block.has_children && block.children && (<Children className="ml-4" children={block.children}/>)}
18+
</div>
1519
);
1620
};

src/components/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ export { Video } from "./Video";
1919
export { Audio } from "./Audio";
2020
export { PDF } from "./PDF";
2121
export { Equation } from "./Equation";
22-
export { ChildPage } from "./ChildPage";
2322
export { ChildDatabase } from "./ChildDatabase";
23+
export { ChildPage } from "./ChildPage";
24+
export { Children } from "./Children";
2425
export { LinkPreview } from "./LinkPreview";
2526
export { Column } from "./Column";
2627
export { ColumnList } from "./ColumnList";

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export { Audio } from "./components/Audio";
2020
export { PDF } from "./components/PDF";
2121
export { Equation } from "./components/Equation";
2222
export { ChildPage } from "./components/ChildPage";
23+
export { Children } from "./components/Children";
2324
export { ChildDatabase } from "./components/ChildDatabase";
2425
export { LinkPreview } from "./components/LinkPreview";
2526
export { Column } from "./components/Column";

src/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { StrictMode } from "react";
22
import { createRoot } from "react-dom/client";
33
import "./styles/index.css";
4-
import App from "./App.tsx";
4+
import App from "./App";
55

66
createRoot(document.getElementById("root")!).render(
77
<StrictMode>

src/types/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { BulletedListItemBlock } from "./bulletedListItem.types";
66
import { CalloutBlock } from "./callout.types";
77
import { ChildDatabaseBlock } from "./childDatabase.types";
88
import { ChildPageBlock } from "./childPage.types";
9+
import { ChildrenBlock } from "./children.types";
910
import { CodeBlock } from "./code.types";
1011
import { ColumnBlock } from "./column.types";
1112
import { ColumnListBlock } from "./columnList.types";
@@ -48,8 +49,9 @@ export type NotionBlock =
4849
| AudioBlock
4950
| PDFBlock
5051
| EquationBlock
51-
| ChildPageBlock
5252
| ChildDatabaseBlock
53+
| ChildPageBlock
54+
| ChildrenBlock
5355
| LinkPreviewBlock
5456
| ColumnBlock
5557
| ColumnListBlock

src/types/paragraph.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ export interface ParagraphBlock extends BaseBlock {
66
rich_text: RichText[];
77
color: string;
88
};
9+
children?: BaseBlock[]
910
}

tsconfig.app.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"skipLibCheck": true,
99
"forceConsistentCasingInFileNames": true,
1010
"declaration": true,
11+
"declarationDir": "./dist",
1112
"outDir": "./dist",
1213
"rootDir": "./src",
1314

@@ -19,7 +20,6 @@
1920
"noEmit": false,
2021
"emitDeclarationOnly": true,
2122
"jsx": "react-jsx",
22-
"resolveJsonModule": true,
2323

2424
"baseUrl": ".",
2525
"paths": {
@@ -34,5 +34,5 @@
3434
"noUncheckedSideEffectImports": true
3535
},
3636
"include": ["src"],
37-
"exclude": ["node_modules"]
38-
}
37+
"exclude": ["node_modules", "dist"]
38+
}

tsconfig.json

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
1+
// {
2+
// "files": [],
3+
// "references": [
4+
// { "path": "./tsconfig.app.json" },
5+
// { "path": "./tsconfig.node.json" }
6+
// ]
7+
// }
8+
19
{
2-
"files": [],
3-
"references": [
4-
{ "path": "./tsconfig.app.json" },
5-
{ "path": "./tsconfig.node.json" }
6-
]
7-
}
10+
"compilerOptions": {
11+
"skipLibCheck": true,
12+
"moduleResolution": "bundler",
13+
"allowSyntheticDefaultImports": true,
14+
"target": "ESNext",
15+
"module": "ESNext",
16+
"esModuleInterop": true,
17+
"jsx": "react-jsx",
18+
"strict": true,
19+
"baseUrl": ".",
20+
"paths": {
21+
"@/*": ["src/*"],
22+
"@components/*": ["src/components/*"],
23+
"@lib/*": ["src/lib/*"],
24+
"@hooks/*": ["src/hooks/*"],
25+
"@ui/*": ["src/components/ui/*"]
26+
},
27+
"noEmit": true
28+
}
29+
}

0 commit comments

Comments
 (0)