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.
- package/README.md +143 -188
- package/bin/chalknotes.js +31 -0
- package/bin/cli.js +27 -288
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +196 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/scaffold.d.ts +6 -0
- package/dist/commands/scaffold.d.ts.map +1 -0
- package/dist/commands/scaffold.js +196 -0
- package/dist/commands/scaffold.js.map +1 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +163 -0
- package/dist/index.js.map +1 -0
- package/dist/notion/client.d.ts +14 -0
- package/dist/notion/client.d.ts.map +1 -0
- package/dist/notion/client.js +191 -0
- package/dist/notion/client.js.map +1 -0
- package/dist/plugins/parser.d.ts +10 -0
- package/dist/plugins/parser.d.ts.map +1 -0
- package/dist/plugins/parser.js +307 -0
- package/dist/plugins/parser.js.map +1 -0
- package/dist/templates/components.d.ts +4 -0
- package/dist/templates/components.d.ts.map +1 -0
- package/dist/templates/components.js +556 -0
- package/dist/templates/components.js.map +1 -0
- package/dist/templates/pages.d.ts +4 -0
- package/dist/templates/pages.d.ts.map +1 -0
- package/dist/templates/pages.js +321 -0
- package/dist/templates/pages.js.map +1 -0
- package/dist/types/index.d.ts +64 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/config.d.ts +12 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +99 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/detection.d.ts +19 -0
- package/dist/utils/detection.d.ts.map +1 -0
- package/dist/utils/detection.js +246 -0
- package/dist/utils/detection.js.map +1 -0
- package/dist/utils/logger.d.ts +10 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +62 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +47 -10
- package/templates/example-config.js +34 -0
- package/templates/example-env +3 -0
- package/src/index.js +0 -10
- package/src/lib/getAllPosts.js +0 -35
- package/src/lib/getPostBySlug.js +0 -380
- package/src/lib/nextHelpers.js +0 -36
- package/src/lib/notion.js +0 -11
- package/src/utils.js +0 -6
package/README.md
CHANGED
|
@@ -1,258 +1,213 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ChalkNotes
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
29
|
+
Create a `.env` file in your project root:
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
NOTION_DATABASE_ID=xxxxxxxxxxxxxxxxxxxxxx
|
|
38
|
-
```
|
|
31
|
+
```env
|
|
32
|
+
NOTION_TOKEN=secret_...
|
|
33
|
+
NOTION_DATABASE_ID=...
|
|
34
|
+
```
|
|
39
35
|
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
npx chalknotes
|
|
43
|
-
```
|
|
36
|
+
### 3. Initialize ChalkNotes
|
|
44
37
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
|
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
|
-
//
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
92
|
+
## 🧩 Plugin System
|
|
73
93
|
|
|
74
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
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
|
-
|
|
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
|
-
##
|
|
124
|
+
## 🎨 Themes
|
|
97
125
|
|
|
98
|
-
###
|
|
126
|
+
### Modern (Default)
|
|
127
|
+
Clean, contemporary design with excellent readability and modern styling.
|
|
99
128
|
|
|
100
|
-
|
|
129
|
+
### Minimal
|
|
130
|
+
Simple, focused layout that puts content first with minimal distractions.
|
|
101
131
|
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
108
|
-
export const getStaticPaths = getStaticPathsForPosts;
|
|
135
|
+
## 📚 API Reference
|
|
109
136
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
151
|
+
```typescript
|
|
152
|
+
// For Pages Router
|
|
153
|
+
import { getStaticPropsForPost, getStaticPathsForPosts } from 'chalknotes';
|
|
129
154
|
|
|
130
|
-
|
|
155
|
+
export const getStaticProps = getStaticPropsForPost;
|
|
156
|
+
export const getStaticPaths = getStaticPathsForPosts;
|
|
131
157
|
|
|
132
|
-
|
|
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
|
-
###
|
|
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
|
-
|
|
191
|
-
|
|
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
|
-
|
|
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
|
-
```
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
|
|
190
|
+
Full TypeScript integration with comprehensive type definitions:
|
|
209
191
|
|
|
210
|
-
|
|
211
|
-
|
|
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
|
-
|
|
198
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
239
199
|
|
|
240
|
-
|
|
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
|
-
##
|
|
204
|
+
## 🔗 Links
|
|
251
205
|
|
|
252
|
-
|
|
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
|
-
|
|
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();
|