@ainame/tuzuru 0.1.0 → 0.1.2

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 ADDED
@@ -0,0 +1,266 @@
1
+ # Tuzuru
2
+
3
+ ![logo](.github/assets/logo.png)
4
+
5
+ Tuzuru (綴る) is dead-simple static **blog** generator CLI that uses Git to manage your blog's metadata.
6
+
7
+ Instead of writing YAML front matter, you just write and save your plain Markdown files to Git. Tuzuru automatically pulls metadata like the publication date and author information from the Git commit history.
8
+
9
+ This means you can focus on what you're writing, not on remembering syntax. It's a simpler, more lightweight way to manage your blog.
10
+
11
+ ## Motivation
12
+
13
+ Years ago, I built a blog with Hugo, but eventually stopped updating it. When I recently wanted to start again, I found it tough to remember and re-learn how to use it.
14
+
15
+ I wanted a simple, intuitive blogging tool, but none I tried felt quite right. So, I decided to build my own.
16
+
17
+ Tuzuru is designed with these core principles:
18
+
19
+ * Plain Markdown: No YAML front matter.
20
+ * Simple Routing: A routing system built specifically for blogs.
21
+ * No JavaScript Framework: Lightweight and fast.
22
+ * Single Binary Installation: Avoids environment setup for tools that you may not use day-to-day
23
+
24
+ ## Installation
25
+
26
+ ### npm (Cross-platform)
27
+
28
+ ```bash
29
+ npm install -g @ainame/tuzuru
30
+ ```
31
+
32
+ This will download and install the appropriate prebuilt binary for your platform (macOS or Linux).
33
+
34
+ ### Homebrew (macOS)
35
+
36
+ ```bash
37
+ brew tap ainame/tuzuru https://github.com/ainame/Tuzuru
38
+ brew install tuzuru
39
+ ```
40
+
41
+ ### Manual Build
42
+
43
+ ```bash
44
+ swift build -c release
45
+ cp .build/release/tuzuru /path/to/bin
46
+ ```
47
+
48
+ ## Getting started
49
+
50
+ You first need to set up a Git repo locally.
51
+
52
+ ```bash
53
+ mkdir new-blog
54
+ cd new-blog
55
+ git init
56
+
57
+ # Initialize a blog project
58
+ # This adds `assets`, `contents`, `templates` directories and `tuzuru.json`
59
+ tuzuru init
60
+
61
+ git add .
62
+ git commit -m "init commit"
63
+ ```
64
+
65
+ Then create a markdown file under the `contents` directory and do `git commit`.
66
+
67
+ ``` bash
68
+ emacs contents/first-blog-post.md
69
+ git add contents/first-blog-post.md
70
+ git commit -m "First post"
71
+ ```
72
+
73
+ When you make `git commit` becomes your post's published date.
74
+ Specifically, the first commit's Author Date for a markdown file under `contents` is the published date and also, author name will be taken from Git's config.
75
+
76
+ Now it's time to build your blog.
77
+
78
+ ``` bash
79
+ tuzuru generate
80
+ ```
81
+
82
+ You can now see the `blog` directory that can be deployed to GitHub Pages or your favorite HTTP server.
83
+
84
+ For local development, use the built-in serve command:
85
+
86
+ ``` bash
87
+ tuzuru serve
88
+ ```
89
+
90
+ This starts a local HTTP server at `http://localhost:8000` with auto-regeneration enabled. When you modify source files, the blog will be automatically rebuilt on the next request.
91
+
92
+ ### Built-in layout
93
+
94
+ The built-in layout is a great starting point and is easy to customize. It already includes [github-markdown-css](https://github.com/sindresorhus/github-markdown-css) and [highlight.js](https://highlightjs.org/) to make writing tech blog posts a breeze.
95
+
96
+
97
+ ![screenshot](.github/assets/screenshot.png)
98
+
99
+ ### Example project structure
100
+
101
+ ```
102
+ my-blog/
103
+ ├── contents/
104
+ │ ├── hello-world.md # → /hello-world
105
+ │ ├── tech/
106
+ │ │ └── swift-tips.md # → /tech/swift-tips (listed on /tech)
107
+ │ └── unlisted/
108
+ │ └── about.md # → /about (not listed anywhere. You can link to /about from layout.mustache manually)
109
+ ├── templates/
110
+ │ ├── layout.mustache
111
+ │ ├── post.mustache
112
+ │ └── list.mustache
113
+ ├── assets/
114
+ │ └── main.css
115
+ └── tuzuru.json
116
+ ```
117
+
118
+ ### Demo
119
+
120
+ You can see Tuzuru in action with this demo blog hosted on GitHub Pages:
121
+
122
+ - **Live Demo**: [https://ainame.tokyo/tuzuru-demo/](https://ainame.github.io/tuzuru-demo/)
123
+ - **Source Repository**: [https://github.com/ainame/tuzuru-demo](https://github.com/ainame/tuzuru-demo)
124
+
125
+ This demo showcases the built-in layout and demonstrates how Tuzuru generates clean, lightweight blog pages from plain Markdown files.
126
+
127
+ ## How it works
128
+
129
+ ### Layout and customization
130
+
131
+ Tuzuru supports two types of pages.
132
+
133
+ 1. Post - a blog article
134
+ 2. List - a listing page generated automatically
135
+
136
+ You can customize these layouts using three Mustache files:
137
+
138
+ * templates/layout.mustache - Base layout
139
+ * templates/post.mustache - main part of post page
140
+ * templates/list.mustache - main part of list page
141
+
142
+ For more on syntax, see the documentation.
143
+ https://docs.hummingbird.codes/2.0/documentation/hummingbird/mustachesyntax/
144
+
145
+ ### Listing and Unlisted Pages
146
+
147
+ By default, any Markdown file in the `contents` directory is automatically listed on:
148
+
149
+ * The home page (`/`) based on your configuration.
150
+ * Yearly archive pages (e.g., `/2025`, `/2024`).
151
+ * Category pages for files in subdirectories (e.g., `contents/tech/swift.md` is listed on `/tech`).
152
+
153
+ You can add an unlisted page by placing it in `contents/unlisted/`. These pages won't be listed anywhere automatically, but you can link to them manually from your templates.
154
+
155
+ ### Assets
156
+
157
+ The `tuzuru init` command creates an assets directory containing `main.css`. The tuzuru generate command copies all files from this directory to `blog/assets`.
158
+
159
+ To prevent browser cache issues, use the `{{buildVersion}}` variable in your templates.
160
+
161
+
162
+ ```mustache
163
+ <link rel="stylesheet" href="{{assetsUrl}}main.css?{{buildVersion}}">
164
+ ```
165
+
166
+ ### tuzuru.json
167
+
168
+ `tuzuru.json` is the main configuration file, though you can omit most settings if you stick to the defaults.
169
+
170
+
171
+ ```javascript
172
+ {
173
+ // `metadata` is the only mandatory section.
174
+ "metadata" : {
175
+ "blogName" : "My Blog",
176
+ "copyright" : "My Blog",
177
+ "description" : "My personal blog", // Meta description for SEO
178
+ "baseUrl" : "https://example.com/", // Production URL
179
+ "locale" : "en_GB" // Affects the published date format
180
+ },
181
+ // `output` for configuring output options
182
+ "output" : {
183
+ "directory" : "blog", // The output directory
184
+ "homePageStyle" : "all", // "all", "pastYear", or a number (last X posts)
185
+ "routingStyle" : "subdirectory" // "subdirectory" (e.g., /hello-world) or "direct" (e.g., /hello-world.html)
186
+ },
187
+ // `sourceLayout` to customize the default directory structure (typically not needed)
188
+ "sourceLayout" : {
189
+ "assets" : "assets",
190
+ "contents" : "contents",
191
+ "imported" : "contents/imported",
192
+ "templates" : {
193
+ "layout" : "templates/layout.mustache",
194
+ "list" : "templates/list.mustache",
195
+ "post" : "templates/post.mustache"
196
+ },
197
+ "unlisted" : "contents/unlisted"
198
+ }
199
+ }
200
+ ```
201
+
202
+ ## Import posts from Hugo project
203
+
204
+ You can import Markdown files from a Hugo project. Tuzuru will parse the YAML front matter to get the title, author, and date, then remove it. Each imported Markdown file will be added as an individual Git commit.
205
+
206
+ ```bash
207
+ tuzuru import /path/to/import-target-dir # import them to ./contents/imported by default
208
+ tuzuru import /path/to/import-target-dir --destination /path/to/import
209
+ ```
210
+
211
+ ## Amend published date or author
212
+
213
+ Need to change a post's published date or author without rewriting your Git history? Use the amend command.
214
+
215
+ ```bash
216
+ # Update published date
217
+ tuzuru amend contents/my-post.md --published-at "2023-12-01"
218
+
219
+ # Update author
220
+ tuzuru amend contents/my-post.md --author "New Author"
221
+
222
+ # Update both
223
+ tuzuru amend contents/my-post.md --published-at "2023-12-01 10:30:00 +0900" --author "New Author"
224
+ ```
225
+
226
+ The command supports flexible date formats:
227
+
228
+ - `2023-12-01` (date only)
229
+ - `2023-12-01 10:30:00` (date and time)
230
+ - `2023-12-01T10:30:00Z` (ISO 8601 UTC)
231
+ - `2023-12-01 10:30:00 +0900` (with timezone)
232
+
233
+ This command creates a special marker commit that Tuzuru recognizes for post metadata, leaving your history clean.
234
+
235
+ ## Local Development Server
236
+
237
+ Tuzuru includes a built-in HTTP server for local development:
238
+
239
+ ```bash
240
+ # Basic usage (serves on port 8000)
241
+ tuzuru serve
242
+
243
+ # Custom port
244
+ tuzuru serve --port 3000
245
+
246
+ # Custom directory (default is 'blog')
247
+ tuzuru serve --directory my-output
248
+
249
+ # Custom config file
250
+ tuzuru serve --config my-config.json
251
+ ```
252
+
253
+ ### Auto-regeneration
254
+
255
+ The serve command automatically watches for changes in your source files and regenerates the blog when needed:
256
+
257
+ - **Content files**: Watches `contents/` and `contents/unlisted/` directories
258
+ - **Asset files**: Watches the `assets/` directory
259
+ - **Templates**: Watches template files for changes
260
+
261
+ When files are modified, the blog is regenerated on the next HTTP request, providing a seamless development experience without manual rebuilds.
262
+
263
+ ## Build Requirements
264
+
265
+ - Swift 6.1+
266
+ - macOS v15+
@@ -27,7 +27,7 @@ function fail(msg) {
27
27
  process.exit(1);
28
28
  }
29
29
 
30
- const pkg = require('../package.json');
30
+ const pkg = require('../../package.json');
31
31
  const version = (pkg.version || '').trim();
32
32
  if (!version || version === '0.0.0') {
33
33
  log('Package version is 0.0.0; attempting to install latest release via GitHub API');
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@ainame/tuzuru",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Tuzuru static blog generator (npm wrapper around prebuilt binaries)",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "bin": {
8
- "tuzuru": "bin/tuzuru.js"
8
+ "tuzuru": "npm/bin/tuzuru.js"
9
9
  },
10
10
  "os": [
11
11
  "darwin",
@@ -27,12 +27,12 @@
27
27
  "url": "https://github.com/ainame/Tuzuru/issues"
28
28
  },
29
29
  "scripts": {
30
- "postinstall": "node scripts/install.js"
30
+ "postinstall": "node npm/scripts/install.js"
31
31
  },
32
32
  "files": [
33
- "bin/",
34
- "scripts/",
35
- "vendor/",
36
- "../README.md"
33
+ "npm/bin/",
34
+ "npm/scripts/",
35
+ "npm/vendor/",
36
+ "README.md"
37
37
  ]
38
38
  }
File without changes