Cabret is a yaml based static site generator, ideally with the same features as Hugo but with a simpler model. Here is a simple example of a _Cabretfile.yaml_
Cabret is based on the idea of a data pipeline. Along a pipeline flows **a list** of `Content` items that are just items with a data, mime type and metadata.
The `Type` is the _mime type_ of the `Data`. The `Metadata` can be whatever the user wants and operations can populate it with special fields as they please. In some cases its useful to have `Data` be `nil`, when that happens the `Type` should be `cabret.MetadataOnly` (just the string `"metadata-only"`)
A **path pattern** is a "glob pattern" with captures, some examples are
```
posts/{id}.md
{{folders}}/{year}-{month}-{day}.json
```
the only difference is that `{{...}}` captures can match slashes so can be used to match more than one "path part", while `{...}` can only match non slash characters.
A **path template** can contains `{...}` interpolations, the key inside the braces will be replaced using the `.Metadata.MatchResult` map. Double braces can also be used and are evaluated using Go `text/template` with context the whole item metadata.
- **Template** is a list operation that will concatenate all incoming items and render them using the specified template engine
```yaml
use: template
engine: <name>
```
for now `engine` can be one of
-`html`— golang html template engine
-`text`— golang text template engine
- (_TODO_) `handlebars`— the famous Handlebars template engine
- **Layout** is an item operation that works like the previous one as it will use a template engine to render the content of the output item. The main difference is that this will pass the previous item content in the template context in the `.Content` field.
This operation will automatically choose between the go html or text template engines based on the first file name extension, _TODO: make this configurable like the `template` operation_)
The template context is the incoming item metadata as well its data passed in the `.Content` variable.
- **Markdown** doesn't need any other options (TODO: add some options to configure _goldmark_)
```yaml
use: markdown
```
This will render each incoming item using goldmark with some reasonable default options.
By default this will also read YAML frontmatter.
- **Frontmatter** as the previous one but just reads frontmatter.
```yaml
use: frontmatter
```
- **Categorize** can be used in the following forms
```yaml
use: categorize
key: <key>
bind: <variable> # optional
```
This will categorize all items based on the provided key, for example if key is `tags` then the incoming list of posts will be converted in a list of empty contents with a `Category` field telling the item's category and an `Items` field containing a list of posts with that tag.
By default the output item category is placed into `Category` but this can be changed with the `bind` option.
- **Program** is an item operation that will run a specified program passing the current item as stdin. The program output is then processed and becomes the new item data.
```yaml
use: program
io: <stdin/stdoutformat> # optional, defaults to "raw"
command: <shellcommand> # required
```
The io format specifies how the current item is passed to the given program
-`raw`— will just pass the item `.Data` raw as stdin to the specified command.
-`json`— will encode the whole item (also including type and metadata) as json ad pass that string as stdin to the specified command.
_TODO: Make the shell command be a go text/template string, for passing metadata directly thorough the command string._