bunki 0.1.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/LICENSE +21 -0
- package/README.md +246 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 KahWee Teng
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# Bunki
|
|
2
|
+
|
|
3
|
+
[](https://github.com/kahwee/bunki/blob/main/LICENSE)
|
|
4
|
+
[](https://github.com/kahwee/bunki/issues)
|
|
5
|
+
|
|
6
|
+
Bunki is an opinionated static site generator built with Bun. It's designed for creating blogs and simple websites with sensible defaults and minimal configuration.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- Markdown content with frontmatter
|
|
11
|
+
- Syntax highlighting for code blocks
|
|
12
|
+
- Tag-based organization
|
|
13
|
+
- Year-based archives
|
|
14
|
+
- Pagination for post listings
|
|
15
|
+
- RSS feed generation
|
|
16
|
+
- Sitemap generation
|
|
17
|
+
- Local development server
|
|
18
|
+
- Simple CLI interface
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
### From npm (Coming soon)
|
|
23
|
+
```bash
|
|
24
|
+
# Install globally
|
|
25
|
+
bun install -g bunki
|
|
26
|
+
|
|
27
|
+
# Or install locally in your project
|
|
28
|
+
bun install bunki
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### From GitHub
|
|
32
|
+
```bash
|
|
33
|
+
# Clone the repository
|
|
34
|
+
git clone git@github.com:kahwee/bunki.git
|
|
35
|
+
cd bunki
|
|
36
|
+
|
|
37
|
+
# Install dependencies
|
|
38
|
+
bun install
|
|
39
|
+
|
|
40
|
+
# Build the project
|
|
41
|
+
bun run build
|
|
42
|
+
|
|
43
|
+
# Link for local development
|
|
44
|
+
bun link
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Quick Start
|
|
48
|
+
|
|
49
|
+
### Initialize a New Site
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Create a new site with default templates and configuration
|
|
53
|
+
bunki init
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
This will:
|
|
57
|
+
- Create a default configuration file (`bunki.config.json`)
|
|
58
|
+
- Set up the required directory structure
|
|
59
|
+
- Create default templates
|
|
60
|
+
- Add a sample blog post
|
|
61
|
+
|
|
62
|
+
### Add Content
|
|
63
|
+
|
|
64
|
+
Create markdown files in the `content` directory with frontmatter:
|
|
65
|
+
|
|
66
|
+
```markdown
|
|
67
|
+
---
|
|
68
|
+
title: Your Post Title
|
|
69
|
+
date: 2023-01-01T12:00:00Z
|
|
70
|
+
tags: [tag1, tag2]
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
Your post content goes here...
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Or use the CLI to create a new post:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
bunki new "Your Post Title" --tags "tag1, tag2"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Generate Your Site
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Generate the static site
|
|
86
|
+
bunki generate
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Preview Your Site
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Start a local development server
|
|
93
|
+
bunki serve
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Then visit http://localhost:3000 in your browser.
|
|
97
|
+
|
|
98
|
+
## Configuration
|
|
99
|
+
|
|
100
|
+
The `bunki.config.json` file contains the configuration for your site:
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{
|
|
104
|
+
"title": "My Blog",
|
|
105
|
+
"description": "A blog built with Bunki",
|
|
106
|
+
"baseUrl": "https://example.com",
|
|
107
|
+
"domain": "blog"
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Directory Structure
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
.
|
|
115
|
+
├── bunki.config.json # Configuration file
|
|
116
|
+
├── content/ # Markdown content
|
|
117
|
+
│ ├── post1.md
|
|
118
|
+
│ └── post2.md
|
|
119
|
+
├── templates/ # Nunjucks templates
|
|
120
|
+
│ ├── base.njk
|
|
121
|
+
│ ├── index.njk
|
|
122
|
+
│ ├── post.njk
|
|
123
|
+
│ ├── tag.njk
|
|
124
|
+
│ ├── tags.njk
|
|
125
|
+
│ ├── archive.njk
|
|
126
|
+
│ └── styles/
|
|
127
|
+
│ └── main.css
|
|
128
|
+
├── public/ # Static files to copy to the site
|
|
129
|
+
│ └── favicon.ico
|
|
130
|
+
└── dist/ # Generated site
|
|
131
|
+
├── index.html
|
|
132
|
+
├── css/
|
|
133
|
+
│ └── style.css
|
|
134
|
+
└── ...
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Templates
|
|
138
|
+
|
|
139
|
+
Bunki uses [Nunjucks](https://mozilla.github.io/nunjucks/) for templating. The templates should be placed in the `templates` directory. The default templates provide a solid starting point for most blogs.
|
|
140
|
+
|
|
141
|
+
## Command Line Interface
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
Usage: bunki [options] [command]
|
|
145
|
+
|
|
146
|
+
An opinionated static site generator built with Bun
|
|
147
|
+
|
|
148
|
+
Options:
|
|
149
|
+
-V, --version output the version number
|
|
150
|
+
-h, --help display help for command
|
|
151
|
+
|
|
152
|
+
Commands:
|
|
153
|
+
init [options] Initialize a new site with default structure
|
|
154
|
+
new [options] <title> Create a new blog post
|
|
155
|
+
generate [options] Generate static site from markdown content
|
|
156
|
+
serve [options] Start a local development server
|
|
157
|
+
help [command] display help for command
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Initialize Command
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
Usage: bunki init [options]
|
|
164
|
+
|
|
165
|
+
Initialize a new site with default structure
|
|
166
|
+
|
|
167
|
+
Options:
|
|
168
|
+
-c, --config <file> Path to config file (default: "bunki.config.json")
|
|
169
|
+
-h, --help display help for command
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### New Post Command
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
Usage: bunki new [options] <title>
|
|
176
|
+
|
|
177
|
+
Create a new blog post
|
|
178
|
+
|
|
179
|
+
Arguments:
|
|
180
|
+
title Title of the post
|
|
181
|
+
|
|
182
|
+
Options:
|
|
183
|
+
-t, --tags <tags> Comma-separated list of tags (default: "")
|
|
184
|
+
-h, --help display help for command
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Generate Command
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
Usage: bunki generate [options]
|
|
191
|
+
|
|
192
|
+
Generate static site from markdown content
|
|
193
|
+
|
|
194
|
+
Options:
|
|
195
|
+
-c, --config <file> Config file path (default: "bunki.config.json")
|
|
196
|
+
-c, --content <dir> Content directory (default: "content")
|
|
197
|
+
-o, --output <dir> Output directory (default: "dist")
|
|
198
|
+
-t, --templates <dir> Templates directory (default: "templates")
|
|
199
|
+
-h, --help display help for command
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Serve Command
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
Usage: bunki serve [options]
|
|
206
|
+
|
|
207
|
+
Start a local development server
|
|
208
|
+
|
|
209
|
+
Options:
|
|
210
|
+
-o, --output <dir> Output directory (default: "dist")
|
|
211
|
+
-p, --port <number> Port number (default: "3000")
|
|
212
|
+
-h, --help display help for command
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Programmatic Usage
|
|
216
|
+
|
|
217
|
+
You can also use Bunki programmatically in your own Node.js or Bun scripts:
|
|
218
|
+
|
|
219
|
+
```javascript
|
|
220
|
+
import { SiteGenerator, loadConfig } from 'bunki';
|
|
221
|
+
import path from 'path';
|
|
222
|
+
|
|
223
|
+
// Load configuration
|
|
224
|
+
const config = loadConfig('bunki.config.json');
|
|
225
|
+
|
|
226
|
+
// Create a generator
|
|
227
|
+
const generator = new SiteGenerator({
|
|
228
|
+
contentDir: path.join(process.cwd(), 'content'),
|
|
229
|
+
outputDir: path.join(process.cwd(), 'dist'),
|
|
230
|
+
templatesDir: path.join(process.cwd(), 'templates'),
|
|
231
|
+
config
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// Generate site
|
|
235
|
+
async function generate() {
|
|
236
|
+
await generator.initialize();
|
|
237
|
+
await generator.generate();
|
|
238
|
+
console.log('Site generation complete!');
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
generate().catch(console.error);
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## License
|
|
245
|
+
|
|
246
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bunki",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "An opinionated static site generator built with Bun",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "bun build ./src/index.ts --outdir ./dist --target node",
|
|
11
|
+
"dev": "bun run --watch src/index.ts",
|
|
12
|
+
"test": "bun test",
|
|
13
|
+
"format": "prettier --write ."
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"bunki": "./dist/cli.js"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"static-site-generator",
|
|
20
|
+
"markdown",
|
|
21
|
+
"blog",
|
|
22
|
+
"bun",
|
|
23
|
+
"typescript"
|
|
24
|
+
],
|
|
25
|
+
"author": "KahWee Teng",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/kahwee/bunki.git"
|
|
30
|
+
},
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/kahwee/bunki/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/kahwee/bunki#readme",
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"commander": "^11.1.0",
|
|
37
|
+
"fs-extra": "^11.2.0",
|
|
38
|
+
"gray-matter": "^4.0.3",
|
|
39
|
+
"highlight.js": "^11.9.0",
|
|
40
|
+
"marked": "^9.1.5",
|
|
41
|
+
"marked-highlight": "^2.0.7",
|
|
42
|
+
"nunjucks": "^3.2.4",
|
|
43
|
+
"sanitize-html": "^2.11.0",
|
|
44
|
+
"slugify": "^1.6.6"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/fs-extra": "^11.0.4",
|
|
48
|
+
"@types/marked": "^5.0.2",
|
|
49
|
+
"@types/node": "^20.10.0",
|
|
50
|
+
"@types/nunjucks": "^3.2.5",
|
|
51
|
+
"@types/sanitize-html": "^2.9.5",
|
|
52
|
+
"bun-types": "latest",
|
|
53
|
+
"prettier": "^3.1.0",
|
|
54
|
+
"typescript": "^5.2.2"
|
|
55
|
+
},
|
|
56
|
+
"files": [
|
|
57
|
+
"dist",
|
|
58
|
+
"LICENSE",
|
|
59
|
+
"README.md"
|
|
60
|
+
],
|
|
61
|
+
"engines": {
|
|
62
|
+
"bun": ">=1.0.0"
|
|
63
|
+
}
|
|
64
|
+
}
|