Skip to content

Commit 8d0c951

Browse files
committed
feat: update documentation to fssg 1.3
1 parent 0eb5046 commit 8d0c951

File tree

4 files changed

+423
-443
lines changed

4 files changed

+423
-443
lines changed

README.md

Lines changed: 91 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
1-
<p align="center">
2-
<a href="https://github.com/xlc-dev/fssg">
3-
<img src="./src/static/img/logo.png" alt="fssg Logo" width="150">
4-
</a>
5-
</p>
6-
7-
# fssg
8-
9-
**fssg** is a POSIX-compliant, lightweight static site generator written entirely in shell. It converts Markdown and HTML files under `src/` into a ready-to-deploy `dist/` directory, with support for templating, includes, conditionals, pagination, asset hoisting, and more—no external dependencies required beyond standard POSIX utilities.
10-
11-
<p align="center">
12-
<a href="https://opensource.org/licenses/MIT">
13-
<img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square" alt="MIT License">
14-
</a>
15-
<img src="https://img.shields.io/badge/POSIX-Compliant-brightgreen.svg?style=flat-square" alt="POSIX Compliant">
16-
<a href="https://github.com/xlc-dev/fssg/stargazers">
17-
<img src="https://img.shields.io/github/stars/xlc-dev/fssg.svg?style=flat-square&logo=github" alt="GitHub Stars">
18-
</a>
19-
</p>
20-
21-
---
1+
<div style="display: flex; align-items: center; justify-content: space-between;">
2+
<div style="flex: 1;">
3+
<h1>fssg</h1>
4+
<p><strong>fssg</strong> is a portable, dependency-free static site generator written entirely
5+
in POSIX shell and AWK. It recursively processes Markdown (.md) and .html
6+
files in <code>src/</code> and outputs a minified, deployable website in <code>dist/</code>.</p>
7+
</div>
8+
<div>
9+
<a href="https://github.com/xlc-dev/fssg">
10+
<img src="./src/static/img/logo.png" alt="fssg Logo" width="150">
11+
</a>
12+
</div>
13+
</div>
2214

2315
## Table of Contents
2416

@@ -32,49 +24,40 @@
3224
8. [Advanced Features](#advanced-features)
3325
9. [License](#license)
3426

35-
---
36-
3727
## Features
3828

3929
- **Pure Shell & POSIX-Compliant**
4030
No runtime dependencies beyond `sh`, `awk`, `sed`, `find`, `cp`, etc.
4131

4232
- **Markdown & HTML Support**
43-
Built-in Markdown-to-HTML parser (headings, lists, tables, bold/italic, links).
33+
Built-in Markdown-to-HTML parser with support for headings, paragraphs, blockquotes, lists, tables, links, images, code blocks, and more.
4434

4535
- **Templating**
46-
Global `src/template.html` with `{{title}}` and `{{content}}` placeholders.
36+
Global `src/template.html` with `{{title}}` and `{{content}}` placeholders, plus `{{BASE_URL}}` for proper asset paths.
4737

4838
- **Includes & Blocks**
49-
`{{ include:foo.html }}` and `{{ include-block:foo.html param="value" }}` for reusable snippets.
39+
`{{ include:foo.html }}` and `{{ include-block:foo.html param="value" }}` for reusable snippets with optional Markdown processing.
5040

5141
- **Conditional Rendering**
52-
`{{ IF_EXT:md }}…{{ ENDIF_EXT }}` or `{{ IF_PAGE:about.html }}` to show/hide content.
53-
54-
- **Post Listings**
55-
`{{ recent-posts count="5" }}` and `{{ all-posts page_size="10" pagination="true" }}` with auto-pagination.
42+
`{{ IF_EXT:md }}...{{ ENDIF_EXT }}` or `{{ IF_PAGE:about.html }}` to show/hide content based on file extension or output path.
5643

5744
- **Asset Pipeline**
58-
Copies `src/static/` to `dist/static/`, hoists & de-duplicates `<style>` and `<script>` blocks.
45+
Copies `src/static/` to `dist/static/`, hoists `<style>` and `<script>` blocks to appropriate locations.
5946

6047
- **Developer Conveniences**
61-
Watch mode (`-w`), built-in server (`-s` + `mongoose`), auto-open (`-o`), parallel builds (`-j`).
62-
63-
---
48+
Watch mode (`-w`), built-in server (`-s` with multiple server options), auto-open (`-o`), parallel builds (`-j` with default of 100), and auto-reload functionality.
6449

6550
## Prerequisites
6651

6752
- A POSIX-compliant shell (`sh`, `bash`, `dash`, `zsh`, etc.)
6853
- Standard POSIX utilities: `awk`, `sed`, `find`, `cp`, `mkdir`, `rm`, `chmod`, etc.
6954

70-
---
71-
7255
## Installation
7356

7457
### 1. Download the script
7558

7659
```sh
77-
wget https://github.com/xlc-dev/fssg/raw/main/fssg
60+
wget https://raw.githubusercontent.com/xlc-dev/fssg/main/fssg
7861
chmod +x fssg
7962
```
8063

@@ -91,22 +74,18 @@ cp -r fssg/mongoose ./my-site/mongoose/
9174
chmod +x ./my-site/fssg
9275
```
9376

94-
---
95-
9677
## Quick Start
9778

9879
1. **Create your project structure** (see next section).
9980
2. **Write content** in `src/` as `.md` or `.html`.
10081
3. **Run the generator**:
10182

102-
```sh
103-
./fssg
104-
```
83+
```sh
84+
./fssg
85+
```
10586

10687
4. **Browse output** in `dist/`.
10788

108-
---
109-
11089
## Directory Layout
11190

11291
```plain
@@ -125,35 +104,41 @@ your-project/
125104

126105
- `template.html`: contains your `<head>`/`<body>` skeleton.
127106
- `src/*.md|html`: content files—Markdown is auto-converted.
128-
- `src/includes/`: files for `{{ include: }}` and `{{ include-block: }}`.
107+
- `src/includes/`: files for `{{ include:... }}` and `{{ include-block:... }}`.
129108
- `src/static/`: copied verbatim to `dist/static/`.
130109

131-
---
132-
133110
## Command-Line Options
134111

135112
```text
136113
./fssg [options]
137114
```
138115

139-
- `-h` Show help and exit
140-
- `-q` Quiet mode (errors only)
141-
- `-v` Verbose mode (build details)
142-
- `-n` No color in output
143-
- `-w` Watch `src/` for changes and rebuild
144-
- `-s` Start local server (requires `mongoose/`)
145-
- `-o` Auto-open browser (requires `-s`)
146-
- `-j <num>` Parallel build jobs (default: 4)
147-
148-
---
116+
- `-h, --help` Show help and exit
117+
- `-V, --version` Print the script's version and exit
118+
- `-q, --quiet` Quiet mode (errors only)
119+
- `-v, --verbose` Verbose mode (build details)
120+
- `-n, --nocolor` No color in output
121+
- `-w, --watch` Watch `src/` for changes and rebuild
122+
- `-s, --serve` Start local server (prefers mongoose, falls back to python)
123+
- `-o, --open` Auto-open browser (requires `-s`)
124+
- `-m, --minify` Disable HTML minification (enabled by default)
125+
- `-j <num>` Parallel build jobs (default: 100)
126+
127+
### Environment Variables
128+
129+
- `FSSG_BASE_URL`: Base URL for the website (default: empty string)
130+
- `FSSG_SERVER_CMD`: Override the server command used by `-s`
131+
- `FSSG_SERVER_PORT`: Port used by the dev server (default: 8000)
132+
- `FSSG_AWK`: Custom command for the awk executable (default: awk)
133+
- `FSSG_AWK_OPTS`: Custom options for the awk executable (default: none)
149134

150135
## Usage Examples
151136

152137
### Basic Page
153138

154139
`src/index.md`:
155140

156-
```markdown
141+
````markdown
157142
{{title: Home}}
158143

159144
# Welcome to My Site
@@ -169,7 +154,7 @@ This site is generated by **fssg**.
169154
<head>
170155
<meta charset="UTF-8" />
171156
<title>{{title}}</title>
172-
<link rel="stylesheet" href="/static/style.css" />
157+
<link rel="stylesheet" href="{{BASE_URL}}/static/style.css" />
173158
</head>
174159
<body>
175160
{{content}}
@@ -198,43 +183,68 @@ Usage in a page:
198183
{{ include:footer.html }}
199184
```
200185

186+
### Include-Block with Parameters
187+
188+
`src/includes/alert.html`:
189+
190+
```html
191+
<div class="alert alert-{{type}}">
192+
<h4>{{alert_title}}</h4>
193+
{{content}}
194+
</div>
195+
```
196+
197+
Usage in a page:
198+
199+
```html
200+
{{ include-block:alert.html type="warning" alert_title="Attention" markdown="true" }}
201+
This is **Markdown** content inside the block.
202+
{{ endinclude }}
203+
```
204+
201205
### Conditional Content
202206

203207
```html
204208
{{ IF_EXT:md }}
205-
<p>This only appears in Markdown-converted pages.</p>
206-
{{ ENDIF_EXT }} {{ IF_PAGE:about.html }}
207-
<p>This is the About page.</p>
209+
<p>This only appears in Markdown-converted pages.</p>
210+
{{ ENDIF_EXT }}
211+
212+
{{ IF_PAGE:about.html }}
213+
<p>This only appears in Markdown-converted pages.</p>
208214
{{ ENDIF_PAGE }}
209215
```
210216

211-
### Post Listing
217+
### Development Workflow
212218

213-
```html
214-
<h2>Latest Posts</h2>
215-
{{ recent-posts count="3" ul_class="posts" li_class="post" show_images="true" }}
216-
```
219+
```sh
220+
# Build with verbose output
221+
./fssg -v
222+
223+
# Build and start server with auto-reload
224+
./fssg -s -w -o
217225

218-
---
226+
# Build with 200 parallel jobs for large sites
227+
./fssg -j 200
228+
```
219229

220230
## Advanced Features
221231

222-
- **Inline Parameters** in `include-block`:
223-
```html
224-
{{ include-block:card.html title="Hello" }}
225-
<p>Block content goes here</p>
226-
{{ endinclude }}
227-
```
228-
- **Pagination** with `all-posts`:
229-
```html
230-
{{ all-posts page_size="5" page="2" pagination="true" }}
231-
```
232232
- **Style & Script Hoisting**:
233-
All `<style>` tags move to `<head>`, `<script>` tags to end of `<body>`, deduplicated.
233+
All `<style>` tags move to `<head>`, `<script>` tags to end of `<body>`, preserving discovery order.
234234

235-
For full details, see the [fssg Documentation Website](https://xlc-dev.github.io/fssg/).
235+
- **Minification**:
236+
Enabled by default, removes HTML comments, extra whitespace, and CSS/JS comments. Disable with `-m` for debugging.
236237

237-
---
238+
- **Auto-reload**:
239+
When using `-w` or `-s`, fssg injects a script that polls `/.reload` to trigger browser refreshes on changes.
240+
241+
- **Server Selection**:
242+
The `-s` flag prefers a local `./mongoose` binary, then system `mongoose`, then falls back to Python's HTTP server.
243+
244+
- **Parallel Processing**:
245+
Pages are processed in parallel child processes with configurable concurrency (default: 100).
246+
247+
For full details, see the [fssg Documentation Website](https://xlc-dev.github.io/fssg/).
238248

239249
## License
240250

0 commit comments

Comments
 (0)