noblog 0.1.1 → 0.2.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 CHANGED
@@ -1,87 +1,208 @@
1
- # noblog
1
+ # 📝 Noblog
2
2
 
3
- This package aims to generate static content from notion.so and provide a plugable component/theme market for you bloggers.
3
+ > Transform your Notion content into beautiful static blogs with Astro
4
4
 
5
- the pattern would be like notablog (see reference), but more flexiable thanks to the mighty power of Astro
5
+ [![npm version](https://badge.fury.io/js/noblog.svg)](https://badge.fury.io/js/noblog)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
7
 
7
- # Usage
8
+ Noblog generates static content from Notion databases and provides a pluggable component/theme marketplace for bloggers. Inspired by [notablog](https://github.com/dragonman225/notablog) but more flexible thanks to the power of Astro.
8
9
 
10
+ ## 🆚 Why Noblog vs notion-to-md?
11
+
12
+ While Noblog uses [notion-to-md](https://github.com/souvikinator/notion-to-md) under the hood, it provides significant improvements for blog generation:
13
+
14
+ ### 🔧 **Enhanced Markdown Generation**
15
+
16
+ **Problem with notion-to-md:**
17
+ When dealing with complex formatting like nested styles (e.g., `{BLOCK1}` and `{BLOCK2}` both bold, but only `BLOCK1` also italic), notion-to-md generates malformed markdown:
18
+
19
+ ```markdown
20
+ _**BLOCK1**_**BLOCK2** # Broken: unmerged tags
21
+ ```
22
+
23
+ **Noblog's Solution:**
24
+
25
+ - **Merged Tag Handling**: Properly merges nested formatting tags
26
+ - **Clean Markdown Output**: Generates valid, renderer-friendly markdown
27
+ - **Astro-Optimized**: Specifically designed for static site generation
28
+
29
+ ### 🏗️ **Complete Blog Structure**
30
+
31
+ **notion-to-md:** Just converts pages to markdown
32
+
33
+ **Noblog:**
34
+
35
+ - ✅ Automatic file structure generation
36
+ - ✅ Parent/child page organization
37
+ - ✅ Astro-compatible frontmatter
38
+ - ✅ Customizable save paths
39
+ - ✅ Layout path customization
40
+ - ✅ Theme marketplace ready
41
+
42
+ ### ⚡ **One-Command Solution**
43
+
44
+ Instead of manually handling notion-to-md output and building your own file structure:
45
+
46
+ ```bash
47
+ # With Noblog - everything handled automatically
48
+ noblog --layout ../../layouts/BlogLayout.astro
49
+
50
+ # With notion-to-md - you'd need to build everything yourself
9
51
  ```
52
+
53
+ > **Note:** Noblog includes improvements to notion-to-md's core parsing logic, fixing edge cases like unmerged formatting tags that can break markdown renderers.
54
+
55
+ ## 🚀 Quick Start
56
+
57
+ ### Installation
58
+
59
+ ```bash
10
60
  npm install -g noblog
61
+ ```
62
+
63
+ ### Basic Usage
64
+
65
+ ```bash
11
66
  noblog
12
67
  ```
13
68
 
14
- 1. \[OPTIONAL\] Duplicate this [database](https://www.notion.so/humbornjo/fa0faae85c504934a4a86cfa70302850?v=2abd1079ae134fbd8df2604765baa1df) and write blogs on it.
69
+ That's it! Noblog will fetch your Notion content and generate static markdown files.
70
+
71
+ ### 🛠️ Command-Line Options
15
72
 
16
- 2. Find a astro template, here is a shabby template I made: [nobloger](https://github.com/humbornjo/nobloger)
73
+ Noblog supports various command-line options to customize your blog generation:
17
74
 
18
- 3. set two env variables:
75
+ ```bash
76
+ # Basic usage with default settings
77
+ noblog
19
78
 
20
- ```
21
- NOBLOG_DATABASE_ID: your notion database id.
22
- NOTION_API_SECRET: your notion api secret.
23
- ```
79
+ # Custom layout path
80
+ noblog --layout ../../layouts/BlogLayout.astro
24
81
 
25
- 4. Run `noblog` and deploy your site.
82
+ # Custom save and sub paths with layout
83
+ noblog ./content/blog/ ./content/blog/subpages/ --layout ../../../layouts/CustomLayout.astro
26
84
 
27
- By default, `noblog` saves all your post (the posts at the surface og your database) under `SAVE_PATH`.
85
+ # Verbose output for debugging
86
+ noblog -v
87
+ # or
88
+ noblog --verbose
89
+ ```
28
90
 
29
- The articles that are not directly posted on the database is saved under `SAVE_PATH/SUB_PATH`.
91
+ **Available Options:**
30
92
 
31
- The default value of `SAVE_PATH` is `./src/pages/posts/`, `SUB_PATH` is `nob_children/`
93
+ - `--layout PATH` - Custom layout path relative to the posts directory (default: `../../layouts/MarkdownPostLayout.astro`)
94
+ - `-v, --verbose` - Print more messages for debugging
95
+ - `-h, --help` - Show help message
96
+ - `--version` - Show version information
32
97
 
33
- So if you run `noblog` only, the file structure would be,
98
+ **Positional Arguments:**
34
99
 
100
+ - `SAVE_PATH` - Directory to save main posts (default: `./src/pages/posts/`)
101
+ - `SUB_PATH` - Subdirectory for nested content (default: `nob_children/`)
102
+
103
+ ## 📋 Setup Guide
104
+
105
+ ### 1. Create Your Notion Database
106
+
107
+ Duplicate this [template database](https://www.notion.so/humbornjo/fa0faae85c504934a4a86cfa70302850?v=2abd1079ae134fbd8df2604765baa1df) and start writing your blog posts in Notion.
108
+
109
+ ### 2. Configure Environment Variables
110
+
111
+ Set up your Notion API credentials:
112
+
113
+ ```bash
114
+ export NOBLOG_DATABASE_ID="your-notion-database-id"
115
+ export NOTION_API_SECRET="your-notion-api-secret"
35
116
  ```
36
- project root
37
- └──src
38
- └── pages
39
-    └── posts
40
-       ├── blog_1.md
41
-       ├── blog_2.md
42
-       └── nob_children
43
-       ├── referenced_blog_1.md
44
-       ├── referenced_blog_2.md
45
-       ├── referenced_blog_3.md
46
-       ├── referenced_blog_4.md
47
-       └── referenced_blog_5.md
48
- ```
49
117
 
50
- Save dir could be altered by add args when running command,
118
+ ### 3. Choose a Template
119
+
120
+ Pick an Astro template that supports Noblog. Here's a starter template: **[nobloger](https://github.com/humbornjo/nobloger)**
121
+
122
+ ### 4. Deploy Your Site
123
+
124
+ Run `noblog` to generate your content, then deploy your Astro site to your preferred hosting platform.
125
+
126
+ ## 📁 File Structure
127
+
128
+ By default, Noblog organizes your content like this:
51
129
 
52
130
  ```
53
- noblog <SAVE_PATH> <SUB_PATH>
131
+ project-root/
132
+ └── src/
133
+ └── pages/
134
+ └── posts/
135
+ ├── blog-post-1.md # Direct database entries
136
+ ├── blog-post-2.md
137
+ └── nob_children/
138
+ ├── sub-post-1.md # Referenced/child pages
139
+ ├── sub-post-2.md
140
+ └── sub-post-3.md
54
141
  ```
55
142
 
56
- At this time, all the generated markdown is with Astro style, which means each file has a frontmatter like this,
143
+ ### Custom Save Paths
144
+
145
+ You can customize the output directories:
57
146
 
147
+ ```bash
148
+ noblog <SAVE_PATH> <SUB_PATH>
149
+
150
+ # Example:
151
+ noblog ./content/blog/ ./content/blog/subpages/
58
152
  ```
153
+
154
+ ## 🎯 Markdown Output
155
+
156
+ Generated markdown files include Astro-compatible frontmatter:
157
+
158
+ ```markdown
59
159
  ---
60
160
  layout: ../../layouts/MarkdownPostLayout.astro
61
- title: "golang blog"
62
- tags: ["lang", "go"]
161
+ title: "Your Blog Post Title"
162
+ tags: ["tag1", "tag2", "tag3"]
63
163
  pubDate: 2024-01-24
64
164
  archived: false
65
- description: "sometimes I hate, sometimes I love. <3"
165
+ description: "Your post description here"
66
166
  ---
167
+
168
+ # Your content starts here...
67
169
  ```
68
170
 
69
- Layout used is hard coded in the name of `./src/layouts/MarkdownPostLayout.astro`
171
+ ## 🔧 Requirements
172
+
173
+ **Any Astro template can be used with Noblog!** The only requirement is that your template includes a layout component.
70
174
 
71
- In addition, any astro template that offer `./src/layouts/MarkdownPostLayout.astro` and use the default blog file structure (please refer to the code block above) is compatiable with `noblog`.
175
+ This means you can use:
176
+
177
+ - ✅ Any existing Astro blog template
178
+ - ✅ Your custom Astro theme
179
+ - ✅ Popular Astro themes from the community
180
+ - ✅ The starter template: **[nobloger](https://github.com/humbornjo/nobloger)**
181
+
182
+ ### Layout Customization
183
+
184
+ By default, Noblog uses `../../layouts/MarkdownPostLayout.astro` as the layout path. You can customize this using the `--layout` option:
185
+
186
+ ```bash
187
+ # Use a custom layout
188
+ noblog --layout ../../layouts/BlogLayout.astro
189
+
190
+ # Use with custom save paths
191
+ noblog ./content/blog/ ./content/blog/subpages/ --layout ../../../layouts/CustomLayout.astro
192
+ ```
72
193
 
73
- # Millstone
194
+ **Important:** The layout path is relative to the posts directory where your markdown files are saved. For example:
195
+ - If your save path is `./src/pages/posts/`, the default layout path `../../layouts/MarkdownPostLayout.astro` points to `./src/layouts/MarkdownPostLayout.astro`
196
+ - If you change the save path to `./content/blog/`, you might need `--layout ../../layouts/CustomLayout.astro` to point to `./content/layouts/CustomLayout.astro`
74
197
 
75
- - \[2024.07.08\] fuck around
76
- - \[2024.07.20\] generate github flavored markdown
77
- - \[2024.09.04\] at least it worked
198
+ Adjust the layout path based on where your Astro layout files are located relative to your posts directory.
78
199
 
79
- # Reference
200
+ ## 🙏 Acknowledgments
80
201
 
81
- I really appreciate their work and effort. I stealed and refactored some :)
202
+ Built upon the excellent work of these projects:
82
203
 
83
- - [notion api](https://developers.notion.com/reference/intro)
84
- - [notion sdk](https://developers.notion.com/docs/getting-started)
85
- - [notion-to-md](https://github.com/souvikinator/notion-to-md)
86
- - [notablog](https://github.com/dragonman225/notablog)
87
- - [astro-notion-blog](https://github.com/otoyo/astro-notion-blog)
204
+ - [Notion API](https://developers.notion.com/reference/intro) - Official Notion API documentation
205
+ - [Notion SDK](https://developers.notion.com/docs/getting-started) - Notion's official SDK
206
+ - [notion-to-md](https://github.com/souvikinator/notion-to-md) - Notion to Markdown converter
207
+ - [notablog](https://github.com/dragonman225/notablog) - Original inspiration
208
+ - [astro-notion-blog](https://github.com/otoyo/astro-notion-blog) - Astro + Notion integration