chalknotes 0.0.34 → 1.0.1
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 +144 -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 +310 -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 +557 -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,214 @@
|
|
|
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 using the `{{PluginName[params]}}` format:
|
|
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
|
+
{{Tweet[tweet-id]}} - Embed Twitter tweets
|
|
105
|
+
{{YouTube[video-id]}} - Embed YouTube videos
|
|
106
|
+
```
|
|
81
107
|
|
|
82
|
-
###
|
|
83
|
-
- Clean white cards with subtle shadows
|
|
84
|
-
- Light gray background
|
|
85
|
-
- Dark text for optimal readability
|
|
86
|
-
- Responsive design with Tailwind CSS
|
|
108
|
+
### Custom Plugins
|
|
87
109
|
|
|
88
|
-
|
|
89
|
-
- Dark background with gray cards
|
|
90
|
-
- White text with proper contrast
|
|
91
|
-
- Inverted typography for dark mode
|
|
92
|
-
- Same responsive layout
|
|
110
|
+
Create custom plugins by registering them in your blog:
|
|
93
111
|
|
|
94
|
-
|
|
112
|
+
```javascript
|
|
113
|
+
import { registerPlugin } from 'chalknotes';
|
|
114
|
+
|
|
115
|
+
registerPlugin({
|
|
116
|
+
name: 'CustomWidget',
|
|
117
|
+
syntax: /\{\{CustomWidget\[([^\]]+)\]\}\}/g,
|
|
118
|
+
render: (match, context) => {
|
|
119
|
+
const config = match[1];
|
|
120
|
+
return `<div class="custom-widget">${config}</div>`;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
```
|
|
95
124
|
|
|
96
|
-
##
|
|
125
|
+
## 🎨 Themes
|
|
97
126
|
|
|
98
|
-
###
|
|
127
|
+
### Modern (Default)
|
|
128
|
+
Clean, contemporary design with excellent readability and modern styling.
|
|
99
129
|
|
|
100
|
-
|
|
130
|
+
### Minimal
|
|
131
|
+
Simple, focused layout that puts content first with minimal distractions.
|
|
101
132
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
import { getStaticPropsForPost, getStaticPathsForPosts } from 'chalknotes';
|
|
105
|
-
import NotionRenderer from './NotionRenderer';
|
|
133
|
+
### Dev
|
|
134
|
+
Developer-focused theme with enhanced code highlighting and terminal-like aesthetics.
|
|
106
135
|
|
|
107
|
-
|
|
108
|
-
export const getStaticPaths = getStaticPathsForPosts;
|
|
136
|
+
## 📚 API Reference
|
|
109
137
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
</main>
|
|
121
|
-
</div>
|
|
122
|
-
);
|
|
123
|
-
}
|
|
138
|
+
### Core Functions
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
import { getAllPosts, getPostBySlug } from 'chalknotes';
|
|
142
|
+
|
|
143
|
+
// Get all published posts
|
|
144
|
+
const posts = await getAllPosts();
|
|
145
|
+
|
|
146
|
+
// Get specific post by slug
|
|
147
|
+
const post = await getPostBySlug('my-post-slug');
|
|
124
148
|
```
|
|
125
149
|
|
|
126
|
-
|
|
150
|
+
### Next.js Helpers
|
|
127
151
|
|
|
128
|
-
|
|
152
|
+
```typescript
|
|
153
|
+
// For Pages Router
|
|
154
|
+
import { getStaticPropsForPost, getStaticPathsForPosts } from 'chalknotes';
|
|
129
155
|
|
|
130
|
-
|
|
156
|
+
export const getStaticProps = getStaticPropsForPost;
|
|
157
|
+
export const getStaticPaths = getStaticPathsForPosts;
|
|
131
158
|
|
|
132
|
-
|
|
133
|
-
// app/blog/[slug]/page.jsx (or custom route)
|
|
159
|
+
// For App Router
|
|
134
160
|
import { getPostBySlug } from 'chalknotes';
|
|
135
|
-
import NotionRenderer from './NotionRenderer';
|
|
136
161
|
|
|
137
162
|
export default async function BlogPost({ params }) {
|
|
138
163
|
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
|
-
);
|
|
164
|
+
return <YourBlogComponent post={post} />;
|
|
152
165
|
}
|
|
153
166
|
```
|
|
154
167
|
|
|
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
|
-
---
|
|
168
|
+
## 🛠 Advanced Usage
|
|
184
169
|
|
|
185
|
-
###
|
|
186
|
-
For use with `getStaticProps` in Page Router.
|
|
170
|
+
### Custom CSS Framework Integration
|
|
187
171
|
|
|
188
|
-
|
|
172
|
+
ChalkNotes automatically detects your CSS framework and generates appropriate styles:
|
|
189
173
|
|
|
190
|
-
|
|
191
|
-
|
|
174
|
+
- **Tailwind CSS**: Uses utility classes with dark mode support
|
|
175
|
+
- **Styled Components**: Generates styled-components with theme integration
|
|
176
|
+
- **CSS Modules**: Creates modular CSS with scoped styles
|
|
177
|
+
- **Plain CSS**: Falls back to inline styles for maximum compatibility
|
|
192
178
|
|
|
193
|
-
|
|
179
|
+
### Error Handling & Caching
|
|
194
180
|
|
|
195
|
-
|
|
196
|
-
React component for rendering Notion blocks (scaffolded in your project):
|
|
181
|
+
Built-in error boundaries and intelligent caching ensure your blog stays online even when the Notion API is unavailable:
|
|
197
182
|
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
183
|
+
```javascript
|
|
184
|
+
// Automatic retry with exponential backoff
|
|
185
|
+
// Intelligent caching with configurable TTL
|
|
186
|
+
// Graceful degradation when API fails
|
|
202
187
|
```
|
|
203
188
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
## 🖼️ Supported Content Types
|
|
189
|
+
### TypeScript Support
|
|
207
190
|
|
|
208
|
-
|
|
191
|
+
Full TypeScript integration with comprehensive type definitions:
|
|
209
192
|
|
|
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
|
|
193
|
+
```typescript
|
|
194
|
+
import type { BlogPost, NotionBlock, ChalkNotesConfig } from 'chalknotes';
|
|
234
195
|
```
|
|
235
196
|
|
|
236
|
-
|
|
197
|
+
## 🤝 Contributing
|
|
237
198
|
|
|
238
|
-
|
|
199
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
239
200
|
|
|
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
|
|
201
|
+
## 📄 License
|
|
247
202
|
|
|
248
|
-
|
|
203
|
+
MIT - see [LICENSE](LICENSE) file for details.
|
|
249
204
|
|
|
250
|
-
##
|
|
205
|
+
## 🔗 Links
|
|
251
206
|
|
|
252
|
-
|
|
207
|
+
- [Documentation](https://chalknotes.dev/docs)
|
|
208
|
+
- [Examples](https://chalknotes.dev/examples)
|
|
209
|
+
- [Plugin Gallery](https://chalknotes.dev/plugins)
|
|
210
|
+
- [GitHub](https://github.com/chalknotes/chalknotes)
|
|
253
211
|
|
|
254
212
|
---
|
|
255
213
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
[NepTune](https://github.com/yourhandle) • MIT License
|
|
214
|
+
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();
|