Crates.io | sigen |
lib.rs | sigen |
version | 0.3.2 |
source | src |
created_at | 2024-05-13 21:13:47.92892 |
updated_at | 2024-06-05 09:37:43.974878 |
description | A simple static site generator |
homepage | |
repository | https://git.sr.ht/~rytec/sigen |
max_upload_size | |
id | 1238873 |
size | 93,450 |
Sigen is a simple static site generator that allows complete control over the generated result. Everything is build around using handlebars template files to generate output.
Usage: sigen [OPTIONS]
Options:
-i, --input <INPUT> source folder location [default: ./]
-o, --output <OUTPUT> output folder location [default: ./output]
-w, --watch Watch files and regenerate on change
-h, --help Print help
-V, --version Print version
This generator works using the following folder structure:
example/
├── data/
│ └── file.yaml
├── markdown/
│ ├── test.md
│ └── test2.md
├── static/
│ └── style.css
└── templates/
├── base.part
├── index.hbs
└── markdown.hbs
Which generates the following output:
output/
├── content/
│ ├── test.html
│ └── test2.html
├── index.html
├── markdown.html
└── static/
└── style.css
data
In the data folder you can place yaml
files with data that will be passed to the templates. The files will be parsed and added to a user_data
object with the filename as identifier. To use data in the file example
, you would use {{user_data.example.xxx}}
.
markdown
All markdown files (.md
) in this folder will be rendered to html and placed in output/content/
. Sigen supports yaml metadata field is the markdown files. Using the metadata the generated output can be influenced. You are free to add any field you like, this data will be passed to the renderer as a variable content
. There are some fields that directly impact the renderer:
renderer
: When the markdown html is generated the output will be rendered using the configured render file found in the templates
folder.datetime
: When give, as a iso8601 formated string, the markdown files will be ordered according to this date. Markdown files without this field will get the timestamp of the current UTC.If the markdown file contains a metadata field renderer
then the markdown file html will be parsed with the specified render template. The html output from the markdown renderer will be passed as a variable content
to the template. All other markdown metadata fields will be stored in a data object and passed to the template renderer.
static
This folder will be copied recursively to the output folder.
templates
All template files are rendered using handlebars, files with a .part
extension will be registers as a partial. All hbs
files will be rendered to html and have access to the partials and markdown file info. Partials will have the same name as their filename, without the extension.
All templates are passed the following json:
{
"markdown_files":[
{
"name":"",
"datetime": "",
"data": {}
}
...
],
"user_data": {},
"git": {
"branch":"",
"rev_short":"",
"rev":""
}
}
Helper functions extending the handlebars renderer.
(format_datetime <datatime> <format>)
: Format datetime strings. Look here for formatting options.