shtola

ssg in rust
git clone https://tilde.team/~marisa/repo/shtola.git
Log | Files | Refs | LICENSE

commit 3a93e9f8fb786350ff951bb8564131d3e1dd9e13
parent 4026577fd5ad676e9fc4c26fd72f642ff1ccf23e
Author: marisa <mokou@posteo.de>
Date:   Tue, 12 Nov 2019 15:56:26 +0100

Add shtola readme

Diffstat:
Ashtola/README.md | 42++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+), 0 deletions(-)

diff --git a/shtola/README.md b/shtola/README.md @@ -0,0 +1,42 @@ +# shtola + +Shtola is a library for generic file processing. It enables you to build your +own applications that function as static site generators! Here's an example: + +``` rust +use shtola::{Shtola, Plugin, IR, ShFile}; +use std::path::PathBuf; + +fn plugin() -> Plugin { + Box::new(|ir: IR| { + // Let's create a hash where we store updated files... + let update_hash: HashMap<PathBuf, ShFile> = HashMap::new(); + // ...get the file we want to update... + let file = ir.files.get("current_time.txt".into()).unwrap(); + // ...update the file and add it to the update hash... + update_hash.insert( + "current_time.txt".into(), + ShFile { content: "12:30".into(), ..file } + ); + // ...and return the whole thing by calculating the union between our hashes! + IR { files: update_hash.union(ir.files), ..ir } + }) +} + +let mut s = Shtola::new(); +s.source("my_source"); +s.destination("my_destination") +s.use(plugin()); +s.build().expect("Build failed!"); +// Now we have a "current_time.txt" file in our destination directory that +// contains "12:30"! +``` + +## Installation + +Add the latest version of Shtola to your `Cargo.toml`. + +## Documentation + +See https://docs.rs/shtola. +