libssg

static site generation library

Build your own executable static generator that includes your building logic instead of using configuration files and command line arguments. Inspired by Hakyll.

```rust use libssg::; / * $ tree * . * ├── Cargo.toml etc * ├── src * │   └── main.rs * ├── css * │   └── *.css * ├── images * │   └── *.png * ├── index.md * ├── posts * │   └── *.md * ├── _site * │   ├── css * │   │   └── *.css * │   ├── images * │   │   └── *.png * │   ├── index.html * │   ├── posts * │   │   └── *.html * │   └── rss.xml * └── templates * ├── default.hbs * └── post.hbs */

fn main() { let mut state = State::new(); state .then(matchpattern( "^posts/*", Route::SetExtension("html"), Renderer::Pipeline(vec![ Renderer::LoadAndApplyTemplate("templates/post.hbs"), Renderer::LoadAndApplyTemplate("templates/default.hbs"), ]), compilerseq( pandoc(), Box::new(|state, path| { let path = path .stripprefix(&state.outputdir().parent().unwrap()) .unwrapor(&path) .topathbuf(); if state.verbosity() > 3 { println!("adding {} to RSS snapshot", path.display()); } let uuid = uuidfrompath(&path); state.addtosnapshot("main-rss-feed".into(), uuid); Default::default() }), ), )) .then(matchpattern( "index.md", Route::SetExtension("html"), Renderer::LoadAndApplyTemplate("templates/default.hbs"), pandoc(), )) .then(copy("^images/", Route::Id)) .then(copy("^css/", Route::Id)) .then(buildrssfeed( "rss.xml".into(), rssfeed( "main-rss-feed".into(), RssItem { title: "example page".into(), description: "example using libssg".into(), link: "http://example.local".into(), lastbuilddate: String::new(), pubdate: "Thu, 01 Jan 1970 00:00:00 +0000".to_string(), ttl: 1800, }, ), )) .finish(); } ```

cargo run and the output is saved at ./_site/.

Set $FORCE, $VERBOSITY (0..5) to change behaviour.