# Sigen   [![builds.sr.ht Status]][build] [builds.sr.ht Status]: https://builds.sr.ht/~rytec.svg?search=sigen [build]: https://builds.sr.ht/~rytec?search=sigen 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 ```shell Usage: sigen [OPTIONS] Options: -i, --input source folder location [default: ./] -o, --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](https://handlebarsjs.com/guide/), 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: ```json { "markdown_files":[ { "name":"", "datetime": "", "data": {} } ... ], "user_data": {}, "git": { "branch":"", "rev_short":"", "rev":"" } } ``` ### Helpers Helper functions extending the handlebars renderer. - `(format_datetime )`: Format datetime strings. Look [here](https://time-rs.github.io/book/api/format-description.html) for formatting options. - All the [handlebars](https://github.com/sunng87/handlebars-rust/blob/master/src/helpers/helper_extras.rs#L6) crate helpers