chalknotes 0.0.34 → 1.0.0

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 (56) hide show
  1. package/README.md +143 -188
  2. package/bin/chalknotes.js +31 -0
  3. package/bin/cli.js +27 -288
  4. package/dist/commands/init.d.ts +6 -0
  5. package/dist/commands/init.d.ts.map +1 -0
  6. package/dist/commands/init.js +196 -0
  7. package/dist/commands/init.js.map +1 -0
  8. package/dist/commands/scaffold.d.ts +6 -0
  9. package/dist/commands/scaffold.d.ts.map +1 -0
  10. package/dist/commands/scaffold.js +196 -0
  11. package/dist/commands/scaffold.js.map +1 -0
  12. package/dist/index.d.ts +53 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +163 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/notion/client.d.ts +14 -0
  17. package/dist/notion/client.d.ts.map +1 -0
  18. package/dist/notion/client.js +191 -0
  19. package/dist/notion/client.js.map +1 -0
  20. package/dist/plugins/parser.d.ts +10 -0
  21. package/dist/plugins/parser.d.ts.map +1 -0
  22. package/dist/plugins/parser.js +307 -0
  23. package/dist/plugins/parser.js.map +1 -0
  24. package/dist/templates/components.d.ts +4 -0
  25. package/dist/templates/components.d.ts.map +1 -0
  26. package/dist/templates/components.js +556 -0
  27. package/dist/templates/components.js.map +1 -0
  28. package/dist/templates/pages.d.ts +4 -0
  29. package/dist/templates/pages.d.ts.map +1 -0
  30. package/dist/templates/pages.js +321 -0
  31. package/dist/templates/pages.js.map +1 -0
  32. package/dist/types/index.d.ts +64 -0
  33. package/dist/types/index.d.ts.map +1 -0
  34. package/dist/types/index.js +3 -0
  35. package/dist/types/index.js.map +1 -0
  36. package/dist/utils/config.d.ts +12 -0
  37. package/dist/utils/config.d.ts.map +1 -0
  38. package/dist/utils/config.js +99 -0
  39. package/dist/utils/config.js.map +1 -0
  40. package/dist/utils/detection.d.ts +19 -0
  41. package/dist/utils/detection.d.ts.map +1 -0
  42. package/dist/utils/detection.js +246 -0
  43. package/dist/utils/detection.js.map +1 -0
  44. package/dist/utils/logger.d.ts +10 -0
  45. package/dist/utils/logger.d.ts.map +1 -0
  46. package/dist/utils/logger.js +62 -0
  47. package/dist/utils/logger.js.map +1 -0
  48. package/package.json +47 -10
  49. package/templates/example-config.js +34 -0
  50. package/templates/example-env +3 -0
  51. package/src/index.js +0 -10
  52. package/src/lib/getAllPosts.js +0 -35
  53. package/src/lib/getPostBySlug.js +0 -380
  54. package/src/lib/nextHelpers.js +0 -36
  55. package/src/lib/notion.js +0 -11
  56. package/src/utils.js +0 -6
package/README.md CHANGED
@@ -1,258 +1,213 @@
1
- # ✏️ ChalkNotes
1
+ # ChalkNotes
2
2
 
3
- **Turn your Notion database into a blog with zero config. Works with Next.js Page Router and App Router.**
3
+ Transform your Notion pages into beautiful developer blogs with intelligent framework detection and plugin architecture.
4
4
 
5
- ---
6
-
7
- ## 🚀 Features
5
+ ## ✨ Features
8
6
 
9
- - 📄 Fetch blog posts from Notion
10
- - 🪄 Auto-generate routes for App Router or Page Router
11
- - ⚙️ Helpers for `getStaticProps` / `getStaticPaths`
12
- - 🎨 Clean, responsive themes (light & dark mode)
13
- - 🔧 Interactive configuration setup
14
- - 📁 Customizable route paths
15
- - 🧠 Minimal setup just run `chalknotes`
16
- - 🖼️ **Rich content support** - Images, code blocks, lists, quotes, and more
17
- - 🔒 **Secure rendering** - React-based component instead of raw HTML
7
+ - 🚀 **Zero Configuration** - Intelligent detection of Next.js setup, CSS frameworks, and project structure
8
+ - 🎨 **Smart Theming** - Multiple themes with automatic CSS framework detection (Tailwind, Styled Components, CSS Modules)
9
+ - 🧩 **Plugin Architecture** - Extensible plugin system with inline syntax parsing (`@@PluginName`)
10
+ - 📱 **Responsive Design** - Mobile-first approach with dark mode support
11
+ - **Performance Optimized** - Built-in caching, error boundaries, and retry mechanisms
12
+ - 🔧 **TypeScript Support** - Full TypeScript integration with comprehensive type definitions
13
+ - 📦 **Framework Agnostic** - Works with both App Router and Pages Router in Next.js
18
14
 
19
- ---
15
+ ## 🚀 Quick Start
20
16
 
21
- ## 📦 Installation
17
+ ### 1. Installation
22
18
 
23
19
  ```bash
24
- pnpm add chalknotes
25
- # or
26
20
  npm install chalknotes
21
+ # or
22
+ yarn add chalknotes
23
+ # or
24
+ pnpm add chalknotes
27
25
  ```
28
26
 
29
- ---
27
+ ### 2. Environment Setup
30
28
 
31
- ## 🧙‍♂️ Quick Start
29
+ Create a `.env` file in your project root:
32
30
 
33
- 1. **Set up environment variables**
34
- ```bash
35
- # Create .env file
36
- NOTION_TOKEN=secret_...
37
- NOTION_DATABASE_ID=xxxxxxxxxxxxxxxxxxxxxx
38
- ```
31
+ ```env
32
+ NOTION_TOKEN=secret_...
33
+ NOTION_DATABASE_ID=...
34
+ ```
39
35
 
40
- 2. **Run the CLI**
41
- ```bash
42
- npx chalknotes
43
- ```
36
+ ### 3. Initialize ChalkNotes
44
37
 
45
- 3. **That's it!** ✅
46
- - Automatically detects if you're using **App Router** or **Page Router**
47
- - Creates `blog.config.js` with default configuration (if needed)
48
- - Generates blog routes with clean, responsive templates
49
- - Supports light and dark themes
50
- - **Renders rich Notion content** with images, code blocks, and more
51
- - **Configures `next.config.js`** for unoptimized images (works with any Notion domain)
38
+ ```bash
39
+ npx chalknotes init
40
+ ```
52
41
 
53
- ---
42
+ This will:
43
+ - Detect your Next.js setup (App Router vs Pages Router)
44
+ - Identify your CSS framework (Tailwind, Styled Components, etc.)
45
+ - Create a `blog.config.js` with intelligent defaults
46
+ - Set up environment variables
47
+
48
+ ### 4. Scaffold Your Blog
49
+
50
+ ```bash
51
+ npx chalknotes scaffold
52
+ ```
53
+
54
+ This generates:
55
+ - Blog pages optimized for your framework
56
+ - NotionRenderer component with your CSS framework
57
+ - Proper TypeScript definitions (if detected)
58
+
59
+ ### 5. Start Blogging
60
+
61
+ Visit `/blog` in your Next.js app to see your Notion content transformed into a beautiful blog!
54
62
 
55
63
  ## 🔧 Configuration
56
64
 
57
- The CLI creates a `blog.config.js` file in your project root. Customize it to match your needs:
65
+ The `blog.config.js` file provides extensive customization options:
58
66
 
59
67
  ```javascript
60
68
  module.exports = {
61
- // Notion Configuration
62
69
  notionToken: process.env.NOTION_TOKEN,
63
70
  notionDatabaseId: process.env.NOTION_DATABASE_ID,
64
-
65
- // Blog Configuration
66
- routeBasePath: '/blog', // Default: '/blog'
67
- theme: 'default', // Options: 'default' (light) or 'dark'
68
- plugins: [],
71
+ routeBasePath: '/blog',
72
+ theme: 'modern', // 'modern' | 'minimal' | 'dev'
73
+ plugins: [
74
+ '@chalknotes/syntax-highlighter',
75
+ '@chalknotes/analytics',
76
+ '@chalknotes/seo'
77
+ ],
78
+ caching: {
79
+ enabled: true,
80
+ ttl: 3600
81
+ },
82
+ errorBoundaries: true,
83
+ customization: {
84
+ colors: {
85
+ primary: '#3b82f6',
86
+ accent: '#8b5cf6'
87
+ }
88
+ }
69
89
  };
70
90
  ```
71
91
 
72
- ### Configuration Options
92
+ ## 🧩 Plugin System
73
93
 
74
- - **`routeBasePath`**: Customize your blog route (e.g., `/posts`, `/articles`)
75
- - **`theme`**: Choose between `'default'` (light mode) or `'dark'` (dark mode)
76
- - **`plugins`**: Array for future plugin support
94
+ ChalkNotes features a powerful plugin architecture with inline syntax parsing. Simply add plugin syntax anywhere in your Notion content:
77
95
 
78
- ---
96
+ ### Built-in Plugins
79
97
 
80
- ## 🎨 Themes
98
+ ```markdown
99
+ @@CommentSection - Add a comment section
100
+ @@TableOfContents - Generate table of contents
101
+ @@ReadingTime - Show estimated reading time
102
+ @@Share[twitter,linkedin] - Add share buttons
103
+ @@CodePen[pen-id] - Embed CodePen
104
+ @@YouTube[video-id] - Embed YouTube videos
105
+ ```
81
106
 
82
- ### Default Theme (Light Mode)
83
- - Clean white cards with subtle shadows
84
- - Light gray background
85
- - Dark text for optimal readability
86
- - Responsive design with Tailwind CSS
107
+ ### Custom Plugins
87
108
 
88
- ### Dark Theme
89
- - Dark background with gray cards
90
- - White text with proper contrast
91
- - Inverted typography for dark mode
92
- - Same responsive layout
109
+ Create custom plugins by registering them in your blog:
93
110
 
94
- ---
111
+ ```javascript
112
+ import { registerPlugin } from 'chalknotes';
113
+
114
+ registerPlugin({
115
+ name: 'CustomWidget',
116
+ syntax: /@@CustomWidget\[([^\]]+)\]/g,
117
+ render: (match, context) => {
118
+ const config = match[1];
119
+ return `<div class="custom-widget">${config}</div>`;
120
+ }
121
+ });
122
+ ```
95
123
 
96
- ## 📚 Usage in Next.js
124
+ ## 🎨 Themes
97
125
 
98
- ### Page Router
126
+ ### Modern (Default)
127
+ Clean, contemporary design with excellent readability and modern styling.
99
128
 
100
- Creates:
129
+ ### Minimal
130
+ Simple, focused layout that puts content first with minimal distractions.
101
131
 
102
- ```js
103
- // pages/blog/[slug].js (or custom route)
104
- import { getStaticPropsForPost, getStaticPathsForPosts } from 'chalknotes';
105
- import NotionRenderer from './NotionRenderer';
132
+ ### Dev
133
+ Developer-focused theme with enhanced code highlighting and terminal-like aesthetics.
106
134
 
107
- export const getStaticProps = getStaticPropsForPost;
108
- export const getStaticPaths = getStaticPathsForPosts;
135
+ ## 📚 API Reference
109
136
 
110
- export default function BlogPost({ post }) {
111
- return (
112
- <div className="min-h-screen bg-gray-50">
113
- <main className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
114
- <article className="bg-white rounded-lg shadow-sm border border-gray-200 p-8">
115
- <h1 className="text-4xl font-bold text-gray-900 mb-6 leading-tight">
116
- {post.title}
117
- </h1>
118
- <NotionRenderer blocks={post.blocks} />
119
- </article>
120
- </main>
121
- </div>
122
- );
123
- }
137
+ ### Core Functions
138
+
139
+ ```typescript
140
+ import { getAllPosts, getPostBySlug } from 'chalknotes';
141
+
142
+ // Get all published posts
143
+ const posts = await getAllPosts();
144
+
145
+ // Get specific post by slug
146
+ const post = await getPostBySlug('my-post-slug');
124
147
  ```
125
148
 
126
- ---
149
+ ### Next.js Helpers
127
150
 
128
- ### App Router
151
+ ```typescript
152
+ // For Pages Router
153
+ import { getStaticPropsForPost, getStaticPathsForPosts } from 'chalknotes';
129
154
 
130
- Creates:
155
+ export const getStaticProps = getStaticPropsForPost;
156
+ export const getStaticPaths = getStaticPathsForPosts;
131
157
 
132
- ```jsx
133
- // app/blog/[slug]/page.jsx (or custom route)
158
+ // For App Router
134
159
  import { getPostBySlug } from 'chalknotes';
135
- import NotionRenderer from './NotionRenderer';
136
160
 
137
161
  export default async function BlogPost({ params }) {
138
162
  const post = await getPostBySlug(params.slug);
139
-
140
- return (
141
- <div className="min-h-screen bg-gray-50">
142
- <main className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
143
- <article className="bg-white rounded-lg shadow-sm border border-gray-200 p-8">
144
- <h1 className="text-4xl font-bold text-gray-900 mb-6 leading-tight">
145
- {post.title}
146
- </h1>
147
- <NotionRenderer blocks={post.blocks} />
148
- </article>
149
- </main>
150
- </div>
151
- );
163
+ return <YourBlogComponent post={post} />;
152
164
  }
153
165
  ```
154
166
 
155
- ---
156
-
157
- ## 🧩 API
158
-
159
- ### `getPostBySlug(slug: string)`
160
- Fetches a post and returns structured data for rendering.
161
-
162
- ```js
163
- const post = await getPostBySlug('my-post-title');
164
- // Returns: { title, slug, blocks, notionPageId }
165
- ```
166
-
167
- ---
168
-
169
- ### `getAllPosts()`
170
- Returns all published posts with metadata:
171
-
172
- ```js
173
- [
174
- {
175
- title: "My First Post",
176
- slug: "my-first-post",
177
- notionPageId: "xxxxxxxx"
178
- },
179
- ...
180
- ]
181
- ```
182
-
183
- ---
167
+ ## 🛠 Advanced Usage
184
168
 
185
- ### `getStaticPropsForPost()`
186
- For use with `getStaticProps` in Page Router.
169
+ ### Custom CSS Framework Integration
187
170
 
188
- ---
171
+ ChalkNotes automatically detects your CSS framework and generates appropriate styles:
189
172
 
190
- ### `getStaticPathsForPosts()`
191
- For use with `getStaticPaths` in Page Router.
173
+ - **Tailwind CSS**: Uses utility classes with dark mode support
174
+ - **Styled Components**: Generates styled-components with theme integration
175
+ - **CSS Modules**: Creates modular CSS with scoped styles
176
+ - **Plain CSS**: Falls back to inline styles for maximum compatibility
192
177
 
193
- ---
178
+ ### Error Handling & Caching
194
179
 
195
- ### `NotionRenderer`
196
- React component for rendering Notion blocks (scaffolded in your project):
180
+ Built-in error boundaries and intelligent caching ensure your blog stays online even when the Notion API is unavailable:
197
181
 
198
- ```jsx
199
- import NotionRenderer from './NotionRenderer';
200
-
201
- <NotionRenderer blocks={post.blocks} />
182
+ ```javascript
183
+ // Automatic retry with exponential backoff
184
+ // Intelligent caching with configurable TTL
185
+ // Graceful degradation when API fails
202
186
  ```
203
187
 
204
- ---
205
-
206
- ## 🖼️ Supported Content Types
188
+ ### TypeScript Support
207
189
 
208
- The `NotionRenderer` component supports all major Notion block types:
190
+ Full TypeScript integration with comprehensive type definitions:
209
191
 
210
- - **Text blocks**: Paragraphs, headings (H1, H2, H3)
211
- - **Lists**: Bulleted and numbered lists
212
- - **Code blocks**: With syntax highlighting support
213
- - **Images**: With captions and Next.js optimization
214
- - **Quotes**: Styled blockquotes
215
- - **Dividers**: Horizontal rules
216
- - **Rich text**: Bold, italic, strikethrough, code, links
217
-
218
- ---
219
-
220
- ## 🎨 Styling
221
-
222
- The generated templates use Tailwind CSS with:
223
- - Clean, minimal design
224
- - Responsive layout
225
- - Typography optimized for readability
226
- - Proper spacing and hierarchy
227
- - Light and dark mode support
228
- - **Rich content styling** for all Notion block types
229
-
230
- Make sure you have Tailwind CSS installed in your project:
231
-
232
- ```bash
233
- npm install -D tailwindcss @tailwindcss/typography
192
+ ```typescript
193
+ import type { BlogPost, NotionBlock, ChalkNotesConfig } from 'chalknotes';
234
194
  ```
235
195
 
236
- ---
196
+ ## 🤝 Contributing
237
197
 
238
- ## 📅 Roadmap
198
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
239
199
 
240
- - [ ] Plugin system for custom components
241
- - [ ] More Notion block support (callouts, bookmarks, toggles)
242
- - [ ] RSS feed support
243
- - [ ] MDX or Markdown output option
244
- - [ ] Custom theme templates
245
- - [ ] Search functionality
246
- - [ ] Categories and tags support
200
+ ## 📄 License
247
201
 
248
- ---
202
+ MIT - see [LICENSE](LICENSE) file for details.
249
203
 
250
- ## 💡 Inspiration
204
+ ## 🔗 Links
251
205
 
252
- Built to scratch an itch while exploring the simplicity of tools like [feather.so](https://feather.so/) and [Notion Blog](https://github.com/ijjk/notion-blog).
206
+ - [Documentation](https://chalknotes.dev/docs)
207
+ - [Examples](https://chalknotes.dev/examples)
208
+ - [Plugin Gallery](https://chalknotes.dev/plugins)
209
+ - [GitHub](https://github.com/chalknotes/chalknotes)
253
210
 
254
211
  ---
255
212
 
256
- ## 🧑‍💻 Author
257
-
258
- [NepTune](https://github.com/yourhandle) • MIT License
213
+ Made with ❤️ for the developer community
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { Command } = require('commander');
4
+ const path = require('path');
5
+
6
+ const program = new Command();
7
+
8
+ program
9
+ .name('chalknotes')
10
+ .description('Transform your Notion pages into beautiful developer blogs')
11
+ .version('1.0.0');
12
+
13
+ program
14
+ .command('init')
15
+ .description('Initialize ChalkNotes in your Next.js project')
16
+ .option('-f, --force', 'overwrite existing configuration')
17
+ .action(async (options) => {
18
+ const { init } = require('../dist/commands/init.js');
19
+ await init(options);
20
+ });
21
+
22
+ program
23
+ .command('scaffold')
24
+ .description('Generate blog pages and components')
25
+ .option('-t, --theme <theme>', 'specify theme to use')
26
+ .action(async (options) => {
27
+ const { scaffold } = require('../dist/commands/scaffold.js');
28
+ await scaffold(options);
29
+ });
30
+
31
+ program.parse();