diff --git a/README.md b/README.md index 9dad127..1118a85 100644 --- a/README.md +++ b/README.md @@ -1,165 +1,144 @@ # Cabret -A yaml based static site generator, ideally with the same features as Hugo but with a simpler model. - -```yaml -entryPoints: - - source: index.html - pipeline: - - layout: layouts/base.html - - target: dist/index.html - - source: posts/{id}.md - pipeline: - - plugin: markdown - - layout: layouts/base.html - - target: dist/posts/{id}/index.html -``` - -## ToDo - -### Tags - -A case of fan-in (get all posts and group by tags) and fan-out (generate all tag pages with back-links to posts) +A yaml based static site generator, ideally with the same features as Hugo but with a simpler model. Here is a basic example of a _Cabretfile.yaml_ ```yaml build: - # Render homepage - pipeline: - source: index.html - - use: layout - path: layout/base.html - - target: dist/index.html - # Render each post - - pipeline: - - source: posts/{id}.md - - use: markdown - - use: layout - path: layouts/base.html - - target: dist/posts/{id}/index.html - # Render "posts" page - - pipeline: - - source: posts/{id}.md - - use: frontmatter - - use: sort - key: publish_date - direction: descending - - use: slice - from: 0 - to: 10 - - use: template - path: layouts/list.html - - use: layout - path: layouts/base.html - - target: dist/posts/index.html - # Render next pages for "posts" page - - pipeline: - - source: posts/{id}.md - - use: frontmatter - - use: sort - key: publish_date - direction: descending - - use: slice - from: 10 - to: end - - use: chunk # paginate items - size: 10 - - use: layout # aggregate this items chunk in a single item - path: layouts/list.html - use: layout path: layouts/base.html - - target: dist/posts/{.Chunk.Index}/index.html - # Render "/tags/{tag}/" pages + - target: dist/index.html - pipeline: - - source: posts/{id}.md - - use: frontmatter - - use: categorize - key: tags # each post contains a metadata field called "tags" - - use: layout - path: layouts/tag.html + - source: posts/{{ .Id }}.md + - plugin: markdown - use: layout path: layouts/base.html - - target: dist/tags/{category}/index.html + - target: dist/posts/{{ .Id }}/index.html ``` -### Pagination +Cabret is based on the idea of a data pipeline. Along a pipeline flows **a list** of `Content` objects that are just -A case of fan-out with (various data leakages) +```go +type Content struct { + Type string + Metadata map[string]any + Data []byte +} +``` -```yaml -entryPoints: - ... - - pipeline: - - plugin: paginate - items: - pipeline: - - source: posts/{id}.md - - plugin: frontmatter - pageSize: 10 - metadataKey: page - pipeline: - - layout: layouts/list.html +The `Type` is the _mime type_ of the `Data`. The `Metadata` can be whatever the user wants and operations and 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`) -``` +## Operations -### Custom DSL +Each pipeline is a list of operations, the first field in an operation must be one of `source`, `use` or `target`. + +- `source: ` + + Load files matching the given pattern and populates the field `.Metadata.MatchResult` with the captures. + + Other supported forms are + + ```yaml + use: source + path: + ``` + + ```yaml + use: source + paths: + - + ... + - + ``` + +- `target: