chalknotes 0.0.31 → 0.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +258 -257
  2. package/bin/cli.js +421 -390
  3. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -1,391 +1,422 @@
1
- #!/usr/bin/env node
2
- const fs = require("fs");
3
- const path = require("path");
4
- const dotenv = require("dotenv");
5
- const readline = require("readline");
6
- dotenv.config();
7
-
8
- console.log("šŸš€ Initializing ChalkNotes...");
9
-
10
- // Check environment variables
11
- if (!process.env.NOTION_TOKEN) {
12
- console.error("āŒ NOTION_TOKEN is not set in .env file");
13
- console.log("šŸ’” Please create a .env file with your NOTION_TOKEN");
14
- process.exit(1);
15
- }
16
-
17
- if (!process.env.NOTION_DATABASE_ID) {
18
- console.error("āŒ NOTION_DATABASE_ID is not set in .env file");
19
- console.log("šŸ’” Please create a .env file with your NOTION_DATABASE_ID");
20
- process.exit(1);
21
- }
22
-
23
- console.log("āœ… Environment variables are set");
24
-
25
- const configPath = path.join(process.cwd(), 'blog.config.js');
26
-
27
- // Check if blog.config.js exists
28
- if (!fs.existsSync(configPath)) {
29
- console.log("\nāŒ blog.config.js not found");
30
- console.log("This file is required to configure your blog settings.");
31
-
32
- const rl = readline.createInterface({
33
- input: process.stdin,
34
- output: process.stdout
35
- });
36
-
37
- rl.question("Would you like to create a default blog.config.js? (y/n): ", (answer) => {
38
- if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
39
- console.log("šŸ“ Creating blog.config.js with default configuration...");
40
-
41
- const configTemplate = `module.exports = {
42
- notionToken: process.env.NOTION_TOKEN,
43
- notionDatabaseId: process.env.NOTION_DATABASE_ID,
44
- routeBasePath: '/blog',
45
- theme: 'default',
46
- plugins: [],
47
- };`.trim();
48
-
49
- fs.writeFileSync(configPath, configTemplate);
50
- console.log("āœ… Created blog.config.js with default configuration");
51
- console.log("\nšŸ’” Now you can re-run 'npx chalknotes' to scaffold your blog pages!");
52
- } else {
53
- console.log("āŒ Please create a blog.config.js file and try again.");
54
- }
55
- rl.close();
56
- });
57
- return;
58
- }
59
-
60
- // Load configuration
61
- let config;
62
- try {
63
- config = require(configPath);
64
- } catch (error) {
65
- console.error("āŒ Error loading blog.config.js:", error.message);
66
- process.exit(1);
67
- }
68
-
69
- // Set defaults for missing config values
70
- config.routeBasePath = config.routeBasePath || '/blog';
71
- config.theme = config.theme || 'default';
72
-
73
- console.log("āœ… Configuration loaded successfully");
74
- console.log(`šŸ“ Route base path: ${config.routeBasePath}`);
75
- console.log(`šŸŽØ Theme: ${config.theme}`);
76
-
77
- // Ask to proceed with scaffolding
78
- console.log("\nšŸ”Ø Ready to scaffold your blog page?");
79
- console.log("This will create a clean, responsive blog template using Tailwind CSS.");
80
- console.log("Press Enter to continue or Ctrl+C to cancel...");
81
-
82
- // Create blog page templates based on theme and route
83
- const pageRouter = path.join(process.cwd(), '/pages')
84
- const appRouter = path.join(process.cwd(), '/app')
85
-
86
- // Generate templates based on theme
87
- function getTemplates(theme, routeBasePath) {
88
- const routePath = routeBasePath.replace(/^\//, ''); // Remove leading slash
89
-
90
- if (theme === 'dark') {
91
- return {
92
- pageRouter: `
93
- import { getStaticPropsForPost, getStaticPathsForPosts } from 'chalknotes';
94
- import NotionRenderer from './NotionRenderer';
95
-
96
- export const getStaticProps = getStaticPropsForPost;
97
- export const getStaticPaths = getStaticPathsForPosts;
98
-
99
- export default function BlogPost({ post }) {
100
- return (
101
- <div className="min-h-screen bg-gray-900">
102
- <main className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
103
- <article className="bg-gray-800 rounded-lg shadow-lg border border-gray-700 p-8">
104
- <h1 className="text-4xl font-bold text-white mb-6 leading-tight">
105
- {post.title}
106
- </h1>
107
- <NotionRenderer blocks={post.blocks} />
108
- </article>
109
- </main>
110
- </div>
111
- );
112
- }`.trim(),
113
- appRouter: `
114
- import { getPostBySlug } from 'chalknotes';
115
- import NotionRenderer from './NotionRenderer';
116
-
117
- export default async function BlogPost({ params }) {
118
- const post = await getPostBySlug(params.slug);
119
-
120
- return (
121
- <div className="min-h-screen bg-gray-900">
122
- <main className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
123
- <article className="bg-gray-800 rounded-lg shadow-lg border border-gray-700 p-8">
124
- <h1 className="text-4xl font-bold text-white mb-6 leading-tight">
125
- {post.title}
126
- </h1>
127
- <NotionRenderer blocks={post.blocks} />
128
- </article>
129
- </main>
130
- </div>
131
- );
132
- }`.trim()
133
- };
134
- } else {
135
- // Default theme (light mode)
136
- return {
137
- pageRouter: `
138
- import { getStaticPropsForPost, getStaticPathsForPosts } from 'chalknotes';
139
- import NotionRenderer from './NotionRenderer';
140
-
141
- export const getStaticProps = getStaticPropsForPost;
142
- export const getStaticPaths = getStaticPathsForPosts;
143
-
144
- export default function BlogPost({ post }) {
145
- return (
146
- <div className="min-h-screen bg-gray-50">
147
- <main className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
148
- <article className="bg-white rounded-lg shadow-sm border border-gray-200 p-8">
149
- <h1 className="text-4xl font-bold text-gray-900 mb-6 leading-tight">
150
- {post.title}
151
- </h1>
152
- <NotionRenderer blocks={post.blocks} />
153
- </article>
154
- </main>
155
- </div>
156
- );
157
- }`.trim(),
158
- appRouter: `
159
- import { getPostBySlug } from 'chalknotes';
160
- import NotionRenderer from './NotionRenderer';
161
-
162
- export default async function BlogPost({ params }) {
163
- const post = await getPostBySlug(params.slug);
164
-
165
- return (
166
- <div className="min-h-screen bg-gray-50">
167
- <main className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
168
- <article className="bg-white rounded-lg shadow-sm border border-gray-200 p-8">
169
- <h1 className="text-4xl font-bold text-gray-900 mb-6 leading-tight">
170
- {post.title}
171
- </h1>
172
- <NotionRenderer blocks={post.blocks} />
173
- </article>
174
- </main>
175
- </div>
176
- );
177
- }`.trim()
178
- };
179
- }
180
- }
181
-
182
- // Create blog page templates
183
- if (fs.existsSync(pageRouter)) {
184
- console.log("āœ… Page router found");
185
- const routePath = config.routeBasePath.replace(/^\//, ''); // Remove leading slash
186
- const slugDir = path.join(pageRouter, routePath, "[slug].js")
187
- const dirPath = path.dirname(slugDir);
188
-
189
- const templates = getTemplates(config.theme, config.routeBasePath);
190
-
191
- // Create NotionRenderer component in the same directory as the blog page
192
- const notionRendererContent = `import React from "react";
193
- import Image from "next/image";
194
-
195
- export default function NotionRenderer({ blocks }) {
196
- if (!blocks || blocks.length === 0) return null;
197
-
198
- return (
199
- <div className="prose prose-lg max-w-none text-slate-700 leading-relaxed dark:prose-invert dark:text-slate-300">
200
- {blocks.map((block, i) => {
201
- switch (block.type) {
202
- case "heading_1":
203
- return <h1 key={i}>{block.text}</h1>;
204
-
205
- case "heading_2":
206
- return <h2 key={i}>{block.text}</h2>;
207
-
208
- case "heading_3":
209
- return <h3 key={i}>{block.text}</h3>;
210
-
211
- case "paragraph":
212
- return <p key={i}>{block.text}</p>;
213
-
214
- case "bulleted_list_item":
215
- return (
216
- <ul key={i} className="list-disc ml-6">
217
- <li>{block.text}</li>
218
- </ul>
219
- );
220
-
221
- case "numbered_list_item":
222
- return (
223
- <ol key={i} className="list-decimal ml-6">
224
- <li>{block.text}</li>
225
- </ol>
226
- );
227
-
228
- case "quote":
229
- return (
230
- <blockquote key={i} className="border-l-4 pl-4 italic text-slate-600 bg-slate-50 p-4 rounded-r">
231
- {block.text}
232
- </blockquote>
233
- );
234
-
235
- case "code":
236
- return (
237
- <pre key={i} className="bg-slate-900 text-slate-100 p-4 rounded-xl overflow-x-auto text-sm">
238
- <code className={\`language-\${block.language}\`}>{block.code}</code>
239
- </pre>
240
- );
241
-
242
- case "divider":
243
- return <hr key={i} className="my-8 border-slate-300" />;
244
-
245
- case "image":
246
- return (
247
- <figure key={i} className="max-w-[400px] mx-auto my-6 px-4">
248
- <Image
249
- src={block.imageUrl}
250
- alt={block.alt || "Image"}
251
- width={400}
252
- height={300}
253
- className="rounded-xl object-contain"
254
- />
255
- {block.caption && (
256
- <figcaption className="text-sm text-center text-slate-500 mt-2 italic">
257
- {block.caption}
258
- </figcaption>
259
- )}
260
- </figure>
261
- );
262
-
263
- default:
264
- return (
265
- <p key={i} className="text-sm text-red-500 italic">
266
- āš ļø Unsupported block: {block.type}
267
- </p>
268
- );
269
- }
270
- })}
271
- </div>
272
- );
273
- }`;
274
-
275
- fs.mkdirSync(dirPath, { recursive: true });
276
- fs.writeFileSync(path.join(dirPath, 'NotionRenderer.jsx'), notionRendererContent);
277
- console.log(`āœ… Created ${routePath}/NotionRenderer.jsx`);
278
-
279
- fs.writeFileSync(slugDir, templates.pageRouter);
280
- console.log(`āœ… Created pages/${routePath}/[slug].js`);
281
-
282
- } else if (fs.existsSync(appRouter)) {
283
- console.log("āœ… App router found");
284
- const routePath = config.routeBasePath.replace(/^\//, ''); // Remove leading slash
285
- const slugDir = path.join(appRouter, routePath, "[slug]", "page.jsx")
286
- const dirPath = path.dirname(slugDir);
287
-
288
- const templates = getTemplates(config.theme, config.routeBasePath);
289
-
290
- // Create NotionRenderer component in the same directory as the blog page
291
- const notionRendererContent = `import React from "react";
292
- import Image from "next/image";
293
-
294
- export default function NotionRenderer({ blocks }) {
295
- if (!blocks || blocks.length === 0) return null;
296
-
297
- return (
298
- <div className="prose prose-lg max-w-none text-slate-700 leading-relaxed dark:prose-invert dark:text-slate-300">
299
- {blocks.map((block, i) => {
300
- switch (block.type) {
301
- case "heading_1":
302
- return <h1 key={i}>{block.text}</h1>;
303
-
304
- case "heading_2":
305
- return <h2 key={i}>{block.text}</h2>;
306
-
307
- case "heading_3":
308
- return <h3 key={i}>{block.text}</h3>;
309
-
310
- case "paragraph":
311
- return <p key={i}>{block.text}</p>;
312
-
313
- case "bulleted_list_item":
314
- return (
315
- <ul key={i} className="list-disc ml-6">
316
- <li>{block.text}</li>
317
- </ul>
318
- );
319
-
320
- case "numbered_list_item":
321
- return (
322
- <ol key={i} className="list-decimal ml-6">
323
- <li>{block.text}</li>
324
- </ol>
325
- );
326
-
327
- case "quote":
328
- return (
329
- <blockquote key={i} className="border-l-4 pl-4 italic text-slate-600 bg-slate-50 p-4 rounded-r">
330
- {block.text}
331
- </blockquote>
332
- );
333
-
334
- case "code":
335
- return (
336
- <pre key={i} className="bg-slate-900 text-slate-100 p-4 rounded-xl overflow-x-auto text-sm">
337
- <code className={\`language-\${block.language}\`}>{block.code}</code>
338
- </pre>
339
- );
340
-
341
- case "divider":
342
- return <hr key={i} className="my-8 border-slate-300" />;
343
-
344
- case "image":
345
- return (
346
- <figure key={i} className="max-w-[400px] mx-auto my-6 px-4">
347
- <Image
348
- src={block.imageUrl}
349
- alt={block.alt || "Image"}
350
- width={400}
351
- height={300}
352
- className="rounded-xl object-contain"
353
- />
354
- {block.caption && (
355
- <figcaption className="text-sm text-center text-slate-500 mt-2 italic">
356
- {block.caption}
357
- </figcaption>
358
- )}
359
- </figure>
360
- );
361
-
362
- default:
363
- return (
364
- <p key={i} className="text-sm text-red-500 italic">
365
- āš ļø Unsupported block: {block.type}
366
- </p>
367
- );
368
- }
369
- })}
370
- </div>
371
- );
372
- }`;
373
-
374
- fs.mkdirSync(dirPath, { recursive: true });
375
- fs.writeFileSync(path.join(dirPath, 'NotionRenderer.jsx'), notionRendererContent);
376
- console.log(`āœ… Created ${routePath}/[slug]/NotionRenderer.jsx`);
377
-
378
- fs.writeFileSync(slugDir, templates.appRouter);
379
- console.log(`āœ… Created app/${routePath}/[slug]/page.jsx`);
380
-
381
- } else {
382
- console.log("āŒ Neither pages/ nor app/ directory found");
383
- console.log("šŸ’” Please make sure you're running this in a Next.js project");
384
- process.exit(1);
385
- }
386
-
387
- console.log("\nšŸŽ‰ Blog page scaffolded successfully!");
388
- console.log(`\nšŸ“ Next steps:`);
389
- console.log("1. Add Tailwind CSS to your project if not already installed");
390
- console.log("2. Start your development server");
1
+ #!/usr/bin/env node
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+ const dotenv = require("dotenv");
5
+ const readline = require("readline");
6
+ dotenv.config();
7
+
8
+ console.log("šŸš€ Initializing ChalkNotes...");
9
+
10
+ // Check environment variables
11
+ if (!process.env.NOTION_TOKEN) {
12
+ console.error("āŒ NOTION_TOKEN is not set in .env file");
13
+ console.log("šŸ’” Please create a .env file with your NOTION_TOKEN");
14
+ process.exit(1);
15
+ }
16
+
17
+ if (!process.env.NOTION_DATABASE_ID) {
18
+ console.error("āŒ NOTION_DATABASE_ID is not set in .env file");
19
+ console.log("šŸ’” Please create a .env file with your NOTION_DATABASE_ID");
20
+ process.exit(1);
21
+ }
22
+
23
+ console.log("āœ… Environment variables are set");
24
+
25
+ const configPath = path.join(process.cwd(), 'blog.config.js');
26
+
27
+ // Check if blog.config.js exists
28
+ if (!fs.existsSync(configPath)) {
29
+ console.log("\nāŒ blog.config.js not found");
30
+ console.log("This file is required to configure your blog settings.");
31
+
32
+ const rl = readline.createInterface({
33
+ input: process.stdin,
34
+ output: process.stdout
35
+ });
36
+
37
+ rl.question("Would you like to create a default blog.config.js? (y/n): ", (answer) => {
38
+ if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
39
+ console.log("šŸ“ Creating blog.config.js with default configuration...");
40
+
41
+ const configTemplate = `module.exports = {
42
+ notionToken: process.env.NOTION_TOKEN,
43
+ notionDatabaseId: process.env.NOTION_DATABASE_ID,
44
+ routeBasePath: '/blog',
45
+ theme: 'default',
46
+ plugins: [],
47
+ };`.trim();
48
+
49
+ fs.writeFileSync(configPath, configTemplate);
50
+ console.log("āœ… Created blog.config.js with default configuration");
51
+ console.log("\nšŸ’” Now you can re-run 'npx chalknotes' to scaffold your blog pages!");
52
+ } else {
53
+ console.log("āŒ Please create a blog.config.js file and try again.");
54
+ }
55
+ rl.close();
56
+ });
57
+ return;
58
+ }
59
+
60
+ // Load configuration
61
+ let config;
62
+ try {
63
+ config = require(configPath);
64
+ } catch (error) {
65
+ console.error("āŒ Error loading blog.config.js:", error.message);
66
+ process.exit(1);
67
+ }
68
+
69
+ // Set defaults for missing config values
70
+ config.routeBasePath = config.routeBasePath || '/blog';
71
+ config.theme = config.theme || 'default';
72
+
73
+ console.log("āœ… Configuration loaded successfully");
74
+ console.log(`šŸ“ Route base path: ${config.routeBasePath}`);
75
+ console.log(`šŸŽØ Theme: ${config.theme}`);
76
+
77
+ // Ask to proceed with scaffolding
78
+ console.log("\nšŸ”Ø Ready to scaffold your blog page?");
79
+ console.log("This will create a clean, responsive blog template using Tailwind CSS.");
80
+ console.log("Press Enter to continue or Ctrl+C to cancel...");
81
+
82
+ // Create blog page templates based on theme and route
83
+ const pageRouter = path.join(process.cwd(), '/pages')
84
+ const appRouter = path.join(process.cwd(), '/app')
85
+
86
+ // Generate templates based on theme
87
+ function getTemplates(theme, routeBasePath) {
88
+ const routePath = routeBasePath.replace(/^\//, ''); // Remove leading slash
89
+
90
+ if (theme === 'dark') {
91
+ return {
92
+ pageRouter: `
93
+ import { getStaticPropsForPost, getStaticPathsForPosts } from 'chalknotes';
94
+ import NotionRenderer from './NotionRenderer';
95
+
96
+ export const getStaticProps = getStaticPropsForPost;
97
+ export const getStaticPaths = getStaticPathsForPosts;
98
+
99
+ export default function BlogPost({ post }) {
100
+ return (
101
+ <div className="min-h-screen bg-gray-900">
102
+ <main className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
103
+ <article className="bg-gray-800 rounded-lg shadow-lg border border-gray-700 p-8">
104
+ <h1 className="text-4xl font-bold text-white mb-6 leading-tight">
105
+ {post.title}
106
+ </h1>
107
+ <NotionRenderer blocks={post.blocks} />
108
+ </article>
109
+ </main>
110
+ </div>
111
+ );
112
+ }`.trim(),
113
+ appRouter: `
114
+ import { getPostBySlug } from 'chalknotes';
115
+ import NotionRenderer from './NotionRenderer';
116
+
117
+ export default async function BlogPost({ params }) {
118
+ const post = await getPostBySlug(params.slug);
119
+
120
+ return (
121
+ <div className="min-h-screen bg-gray-900">
122
+ <main className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
123
+ <article className="bg-gray-800 rounded-lg shadow-lg border border-gray-700 p-8">
124
+ <h1 className="text-4xl font-bold text-white mb-6 leading-tight">
125
+ {post.title}
126
+ </h1>
127
+ <NotionRenderer blocks={post.blocks} />
128
+ </article>
129
+ </main>
130
+ </div>
131
+ );
132
+ }`.trim()
133
+ };
134
+ } else {
135
+ // Default theme (light mode)
136
+ return {
137
+ pageRouter: `
138
+ import { getStaticPropsForPost, getStaticPathsForPosts } from 'chalknotes';
139
+ import NotionRenderer from './NotionRenderer';
140
+
141
+ export const getStaticProps = getStaticPropsForPost;
142
+ export const getStaticPaths = getStaticPathsForPosts;
143
+
144
+ export default function BlogPost({ post }) {
145
+ return (
146
+ <div className="min-h-screen bg-gray-50">
147
+ <main className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
148
+ <article className="bg-white rounded-lg shadow-sm border border-gray-200 p-8">
149
+ <h1 className="text-4xl font-bold text-gray-900 mb-6 leading-tight">
150
+ {post.title}
151
+ </h1>
152
+ <NotionRenderer blocks={post.blocks} />
153
+ </article>
154
+ </main>
155
+ </div>
156
+ );
157
+ }`.trim(),
158
+ appRouter: `
159
+ import { getPostBySlug } from 'chalknotes';
160
+ import NotionRenderer from './NotionRenderer';
161
+
162
+ export default async function BlogPost({ params }) {
163
+ const post = await getPostBySlug(params.slug);
164
+
165
+ return (
166
+ <div className="min-h-screen bg-gray-50">
167
+ <main className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
168
+ <article className="bg-white rounded-lg shadow-sm border border-gray-200 p-8">
169
+ <h1 className="text-4xl font-bold text-gray-900 mb-6 leading-tight">
170
+ {post.title}
171
+ </h1>
172
+ <NotionRenderer blocks={post.blocks} />
173
+ </article>
174
+ </main>
175
+ </div>
176
+ );
177
+ }`.trim()
178
+ };
179
+ }
180
+ }
181
+
182
+ // Create blog page templates
183
+ if (fs.existsSync(pageRouter)) {
184
+ console.log("āœ… Page router found");
185
+ const routePath = config.routeBasePath.replace(/^\//, ''); // Remove leading slash
186
+ const slugDir = path.join(pageRouter, routePath, "[slug].js")
187
+ const dirPath = path.dirname(slugDir);
188
+
189
+ const templates = getTemplates(config.theme, config.routeBasePath);
190
+
191
+ // Create NotionRenderer component in the same directory as the blog page
192
+ const notionRendererContent = `import React from "react";
193
+ import Image from "next/image";
194
+
195
+ export default function NotionRenderer({ blocks }) {
196
+ if (!blocks || blocks.length === 0) return null;
197
+
198
+ return (
199
+ <div className="prose prose-lg max-w-none prose-headings:font-semibold prose-headings:text-gray-900 dark:prose-headings:text-gray-100 prose-p:text-gray-700 dark:prose-p:text-gray-300 prose-li:text-gray-700 dark:prose-li:text-gray-300">
200
+ {blocks.map((block, i) => {
201
+ switch (block.type) {
202
+ case "heading_1":
203
+ return (
204
+ <h1 key={i} className="text-3xl font-bold text-gray-900 dark:text-gray-100 mb-6 mt-8 first:mt-0 border-b border-gray-200 dark:border-gray-700 pb-2">
205
+ {block.text}
206
+ </h1>
207
+ );
208
+
209
+ case "heading_2":
210
+ return (
211
+ <h2 key={i} className="text-2xl font-semibold text-gray-900 dark:text-gray-100 mb-4 mt-6 first:mt-0">
212
+ {block.text}
213
+ </h2>
214
+ );
215
+
216
+ case "heading_3":
217
+ return (
218
+ <h3 key={i} className="text-xl font-medium text-gray-900 dark:text-gray-100 mb-3 mt-5 first:mt-0">
219
+ {block.text}
220
+ </h3>
221
+ );
222
+
223
+ case "paragraph":
224
+ return (
225
+ <p key={i} className="text-gray-700 dark:text-gray-300 leading-relaxed mb-4 last:mb-0">
226
+ {block.text}
227
+ </p>
228
+ );
229
+
230
+ case "bulleted_list_item":
231
+ return (
232
+ <div key={i} className="flex items-start mb-2">
233
+ <div className="w-2 h-2 bg-gray-400 dark:bg-gray-500 rounded-full mt-2 mr-3 flex-shrink-0"></div>
234
+ <p className="text-gray-700 dark:text-gray-300 leading-relaxed">{block.text}</p>
235
+ </div>
236
+ );
237
+
238
+ case "numbered_list_item":
239
+ return (
240
+ <div key={i} className="flex items-start mb-2">
241
+ <span className="text-gray-500 dark:text-gray-400 font-medium mr-3 mt-0.5 flex-shrink-0">{(i + 1)}.</span>
242
+ <p className="text-gray-700 dark:text-gray-300 leading-relaxed">{block.text}</p>
243
+ </div>
244
+ );
245
+
246
+ case "quote":
247
+ return (
248
+ <blockquote key={i} className="border-l-4 border-blue-500 dark:border-blue-400 pl-6 py-4 my-6 bg-blue-50 dark:bg-blue-900/20 rounded-r-lg shadow-sm">
249
+ <p className="text-gray-700 dark:text-gray-300 italic text-lg leading-relaxed">
250
+ {block.text}
251
+ </p>
252
+ </blockquote>
253
+ );
254
+
255
+ case "code":
256
+ return (
257
+ <div key={i} className="my-6">
258
+ <pre className="bg-gray-900 dark:bg-gray-800 text-gray-100 p-4 rounded-lg shadow-md overflow-x-auto text-sm border border-gray-700 dark:border-gray-600">
259
+ <code className={\`language-\${block.language}\`}>{block.code}</code>
260
+ </pre>
261
+ </div>
262
+ );
263
+
264
+ case "divider":
265
+ return (
266
+ <hr key={i} className="my-8 border-gray-200 dark:border-gray-700 shadow-sm" />
267
+ );
268
+
269
+ case "image":
270
+ return (
271
+ <figure key={i} className="my-8">
272
+ <div className="bg-gray-50 dark:bg-gray-800 rounded-lg p-4 shadow-sm border border-gray-200 dark:border-gray-700">
273
+ <Image
274
+ src={block.imageUrl}
275
+ alt={block.alt || "Image"}
276
+ width={400}
277
+ height={300}
278
+ className="rounded-lg object-contain w-full h-auto shadow-sm"
279
+ unoptimized={true}
280
+ />
281
+ {block.caption && (
282
+ <figcaption className="text-sm text-center text-gray-500 dark:text-gray-400 mt-3 italic">
283
+ {block.caption}
284
+ </figcaption>
285
+ )}
286
+ </div>
287
+ </figure>
288
+ );
289
+
290
+ default:
291
+ return (
292
+ <div key={i} className="my-4 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg">
293
+ <p className="text-sm text-yellow-700 dark:text-yellow-300 italic">
294
+ āš ļø Unsupported block type: {block.type}
295
+ </p>
296
+ </div>
297
+ );
298
+ }
299
+ })}
300
+ </div>
301
+ );
302
+ }`;
303
+
304
+ fs.mkdirSync(dirPath, { recursive: true });
305
+ fs.writeFileSync(path.join(dirPath, 'NotionRenderer.jsx'), notionRendererContent);
306
+ console.log(`āœ… Created ${routePath}/NotionRenderer.jsx`);
307
+
308
+ fs.writeFileSync(slugDir, templates.pageRouter);
309
+ console.log(`āœ… Created pages/${routePath}/[slug].js`);
310
+
311
+ } else if (fs.existsSync(appRouter)) {
312
+ console.log("āœ… App router found");
313
+ const routePath = config.routeBasePath.replace(/^\//, ''); // Remove leading slash
314
+ const slugDir = path.join(appRouter, routePath, "[slug]", "page.jsx")
315
+ const dirPath = path.dirname(slugDir);
316
+
317
+ const templates = getTemplates(config.theme, config.routeBasePath);
318
+
319
+
320
+ // Create NotionRenderer component in the same directory as the blog page
321
+ const notionRendererContent = `import React from "react";
322
+ import Image from "next/image";
323
+
324
+ export default function NotionRenderer({ blocks }) {
325
+ if (!blocks || blocks.length === 0) return null;
326
+
327
+ return (
328
+ <div className="prose prose-lg max-w-none text-slate-700 leading-relaxed dark:prose-invert dark:text-slate-300">
329
+ {blocks.map((block, i) => {
330
+ switch (block.type) {
331
+ case "heading_1":
332
+ return <h1 key={i}>{block.text}</h1>;
333
+
334
+ case "heading_2":
335
+ return <h2 key={i}>{block.text}</h2>;
336
+
337
+ case "heading_3":
338
+ return <h3 key={i}>{block.text}</h3>;
339
+
340
+ case "paragraph":
341
+ return <p key={i}>{block.text}</p>;
342
+
343
+ case "bulleted_list_item":
344
+ return (
345
+ <ul key={i} className="list-disc ml-6">
346
+ <li>{block.text}</li>
347
+ </ul>
348
+ );
349
+
350
+ case "numbered_list_item":
351
+ return (
352
+ <ol key={i} className="list-decimal ml-6">
353
+ <li>{block.text}</li>
354
+ </ol>
355
+ );
356
+
357
+ case "quote":
358
+ return (
359
+ <blockquote key={i} className="border-l-4 pl-4 italic text-slate-600 bg-slate-50 p-4 rounded-r">
360
+ {block.text}
361
+ </blockquote>
362
+ );
363
+
364
+ case "code":
365
+ return (
366
+ <pre key={i} className="bg-slate-900 text-slate-100 p-4 rounded-xl overflow-x-auto text-sm">
367
+ <code className={\`language-\${block.language}\`}>{block.code}</code>
368
+ </pre>
369
+ );
370
+
371
+ case "divider":
372
+ return <hr key={i} className="my-8 border-slate-300" />;
373
+
374
+ case "image":
375
+ return (
376
+ <figure key={i} className="max-w-[400px] mx-auto my-6 px-4">
377
+ <Image
378
+ src={block.imageUrl}
379
+ alt={block.alt || "Image"}
380
+ width={400}
381
+ height={300}
382
+ className="rounded-xl object-contain"
383
+ unoptimized={true}
384
+ />
385
+ {block.caption && (
386
+ <figcaption className="text-sm text-center text-slate-500 mt-2 italic">
387
+ {block.caption}
388
+ </figcaption>
389
+ )}
390
+ </figure>
391
+ );
392
+
393
+ default:
394
+ return (
395
+ <p key={i} className="text-sm text-red-500 italic">
396
+ āš ļø Unsupported block: {block.type}
397
+ </p>
398
+ );
399
+ }
400
+ })}
401
+ </div>
402
+ );
403
+ }`;
404
+
405
+ fs.mkdirSync(dirPath, { recursive: true });
406
+ fs.writeFileSync(path.join(dirPath, 'NotionRenderer.jsx'), notionRendererContent);
407
+ console.log(`āœ… Created ${routePath}/[slug]/NotionRenderer.jsx`);
408
+
409
+ fs.writeFileSync(slugDir, templates.appRouter);
410
+ console.log(`āœ… Created app/${routePath}/[slug]/page.jsx`);
411
+
412
+ } else {
413
+ console.log("āŒ Neither pages/ nor app/ directory found");
414
+ console.log("šŸ’” Please make sure you're running this in a Next.js project");
415
+ process.exit(1);
416
+ }
417
+
418
+ console.log("\nšŸŽ‰ Blog page scaffolded successfully!");
419
+ console.log(`\nšŸ“ Next steps:`);
420
+ console.log("1. Add Tailwind CSS to your project if not already installed");
421
+ console.log("2. Start your development server");
391
422
  console.log(`3. Visit ${config.routeBasePath}/[your-post-slug] to see your blog`);