blob: 356471a0b257a28294fed25645a5de10773cddef (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# ssg
`ssg` is a tiny static site generator that can render HTML templates based on
JSON data files.
## Installation
```bash
git clone https://git.sr.ht/~eugenetriguba/ssg
cd ssg
make install
```
If you want to uninstall later:
```
make uninstall
```
## Quick Start
```bash
ssg init mysite
cd mysite
ssg build
ssg serve
```
Open http://localhost:8080 to view your site.
## Directory Structure
```
mysite/
├── data/ # JSON data files (become html template variables)
├── templates/ # HTML templates (rendered to output directory)
├── static/ # Static files (copied unchanged to output directory)
└── dist/ # Output directory (default)
```
## Commands
| Command | Description |
|---------|-------------|
| `ssg init [dir]` | Create a new site |
| `ssg build` | Build the site |
| `ssg serve` | Start local HTTP server |
| `ssg version` | Print version |
| `ssg help [cmd]` | Show man pages |
## Templates
Templates use Go's `html/template` syntax. JSON files in `data/` become
template variables named after the file (minus `.json`).
**data/projects.json:**
```json
[
{"name": "foo", "url": "https://example.com/foo"},
{"name": "bar", "url": "https://example.com/bar"}
]
```
**templates/index.html:**
```html
<ul>
{{range .projects}}
<li><a href="{{.url}}">{{.name}}</a></li>
{{end}}
</ul>
```
## Documentation
See `ssg help` or `man ssg` for full documentation.
|