A resource’s source keeps its records as files: one file per record in a
folder of the project, read into the table when the application starts and
written back on every save.
<!-- content/posts/hello.md -->
---
title: Hello
pinned: true
---
# Hello
The first post.
Format
File
Holds
yaml
hello.yaml
The form’s fields as a YAML document.
json
hello.json
The form’s fields as a JSON object.
markdown
hello.md
The fields as front matter, the body field under it.
The file’s name is the key field: letters, digits, dots, dashes and
underscores. The fields are written in the form’s order. A switch is true or
false, a number input is a number, a repeater is a list, anything else is
text.
Starting the application reads the folder: a file’s record is created or
updated by key, and a record whose file is gone is removed. A file naming a
field the form does not have fails the start, naming the file and the field.
The repository is the project root; git is on the path with a user name and
email configured. Push the branch to publish: a host that builds on push
rebuilds the site.
The pattern’s pages: the build renders it once per set of parameters paths answers.
TableKeys::new(table, column)
One set per value of column, under the parameter of that name; .param(name) renames it.
Paths
A trait for any other answer: async fn params(&self, db) -> Vec<Params>.
lat make:resource --source writes a src/site/<entity>.rs with the component and the PathsReg for /<table>/:slug, registered from the module. A pattern no module answers for is skipped by the build.
When the application starts. Creates or updates each row by key and removes the rest.
push
After a save commits, with the row’s id, the operation, and the key before a rename.
remove
After a delete commits, with the row’s key.
cx.row(id) gives the row as the key, the columns by shape, and the body; cx.source.options holds the keys beyond the ones above; cx.actor names who is writing.