Crates.io | jabberwock |
lib.rs | jabberwock |
version | 0.1.0 |
source | src |
created_at | 2022-09-13 18:10:02.4788 |
updated_at | 2022-09-13 18:10:02.4788 |
description | A simple yet modular static site generator. |
homepage | |
repository | |
max_upload_size | |
id | 664834 |
size | 31,963 |
Jabberwock is a simple static site generator written entirely in Rust, using Hatter as its templating language. It aims to be highly configurable and modular using a system similar to that of Metalsmith, while still being blazing fast and memory-safe.
Unlike some of its contemporaries, Jabberwock is designed as a library rather than an executable or command-line application. It can be added to an existing project, or used in a new one.
Jabberwock can be included as a dependency by adding the following line under the [dependencies]
section of a project's Cargo.toml
file:
jabberwock = "0.1.0"
The copy
, markdown
, templates
, toml
, and transpile
features are enabled by default. These enable the asset copier, Markdown transpiler, Hatter template transpiler, TOML transpiler, and main Hatter transpiler operations respectively.
If desired, they can be disabled:
jabberwock = { version = "0.1.0", default-features = false }
Jabberwock uses a very simple process:
Commonly-used operations for static sites, such as transpiling Markdown, including templates, loading variables from TOML files, and so on are provided by default, but can be removed by disabling the respective features.
For example, the following code reads Hatter files from the input directory, transpiles them to HTML, and writes the results to the output directory:
use jabberwock::Generator;
use jabberwock::builtin::HatterTranspiler;
fn main() {
println!("{:?}", generate());
}
fn generate() -> Result<(), String> {
let mut generator = Generator::source("in/")?; // read input files from "./in/"
generator.apply(HatterTranspiler::new())?; // transpile Hatter files to HTML files
generator.destination("out/") // write output files to "./out/"
}
The modular system allows chaining even more complex operations together. For example, the following code transpiles Hatter files, adds Hatter functions to load variables from TOML, include Hatter files as templates, and include Markdown file contents as HTML, and also copies CSS files to the output:
use jabberwock::Generator;
use jabberwock::builtin::*;
fn main() {
println!("{:?}", generate());
}
fn generate() -> Result<(), String> {
let mut copier = AssetCopier::new();
copier.copy("css/", "css/"); // set up copier to copy all CSS files from "./css" to "./out/css"
let mut generator = Generator::source("in/")?; // read input files from "./in/"
generator.apply(copier)? // include CSS files in the output
.apply(MarkdownTranspiler::source("md/"))? // add Hatter function to include transpiled Markdown from "./md/" inside Hatter files
.apply(TemplateTranspiler::source("tmpl/"))? // add Hatter function to include transpiled templates from "./tmpl/" inside Hatter files
.apply(TomlTranspiler::source("vars/"))? // add Hatter function to load TOML from "./vars/" as variables inside Hatter files
.apply(HatterTranspiler::new())?; // transpile Hatter files to HTML files
generator.destination("out/") // write output files to "./out/"
}
Further information is available in Jabberwock's documentation.
Any of the following two licenses can be selected when using Jabberwock: