Antwerp was a closed-source build program for logicalbranch.github.io. It was ported from Node.js & Pug to Rust & Tera and is now an open-source framework for building static blogs. It's available on crates.io as Antwerp.
Antwerp takes specified resources and copies assets & directories, compiles SCSS stylesheets, and renders Tera templates to generate a static website in a user-defined folder, it also supports multiple builds using seperate instances.
The following build config was used to generate the malekaia.github.io, it's up to date for version 0.2.1 and is available at example/main.rs.
```rust use antwerp::{Antwerp, Post}; use tera::Context;
pub fn build() { // Create a new build instance let mut build: Antwerp = Antwerp::default();
// Define template data for the tera instance build.tera("./public/*/.tera");
// Define config for urls, directories and post paths build.urlroot("https://malekaia.github.io"); build.urlpost("%urlroot/articles/%category/%slug.html"); build.dirresources("./public/"); build.diroutput("./dist/malekaia.github.io/"); build.dirposts("./public/articles//.tera"); build.path_render("articles/%category/%slug.html");
// NOTE: clean can only occur AFTER build.dir_output
has been defined
build.verbose(true);
build.clean(true, true);
// Copy directories build.folder("images//", r".(png|jpg)$", false); build.folder("scripts/vendor/.js", r".js$", false); build.folder("scripts/.js", r".js$", true); build.folder("styles/vendor//", r".(css|woff|woff2)$", false);
// Compile SCSS assets build.scss("styles/app.scss", "styles/app.css"); build.scss("styles/http.scss", "styles/http.css");
// Generate the post list
build.postlist(| unsorted: Vec
// Build "/404.html" template build.route("404.tera", "404.html", &build.empty_context);
// Build HTTP 410 (deleted) templates for output in [ "about/index.html", "contact/index.html", "img/index.html", "info/index.html", "articles/jQuery/howtomodifythejqueryglobalwithoutmodifyingjquery/index.html", "articles/jQuery/howtoscrolltoanelementonclick/index.html", "articles/Node.js/braceexpansioninshelljs/index.html", "articles/WebDevelopment/howtosetupadevelopmentserverusingexpress/index.html", "articles/WebDevelopment/howtosetupadevelopmentserverusingflask/index.html" ] { build.route("410.tera", output, &build.empty_context); }
// Build HTTP 301 (moved) templates for [output, redirect] in [ ["articles/Bootstrap/howtochangethedefaultfontinbootstrap/index.html", "/articles/CSS/how-to-change-the-default-font-in-bootstrap.html"], ["articles/Git/howtoavoidoverusingthegitkeyword/index.html", "/articles/Git/how-to-avoid-retyping-the-git-keyword.html"], ["articles/Go/globbingingo/index.html", "/articles/Go Lang/globbing-in-go.html"], ["articles/HTML/howtoopenhtmllinksinnewtabs/index.html", "/articles/HTML/how-to-open-html-links-in-new-tabs.html"], ["articles/Node.js/environmentdetectioninjavascript/index.html", "/articles/JavaScript/environment-detection-in-javascript.html"], ["articles/Perl/howtounzipanarchiveusingperl/index.html", "/articles/Perl/how-to-call-a-subprocess-in-perl.html"], ["articles/Pip/anintroductiontothepippackagemanager/index.html", "/articles/Python/an-introduction-to-the-pip-package-manager.html"], ["articles/SASS/howtoextendparentselectorsinsass/index.html", "/articles/CSS/how-to-extend-parent-selectors-in-sass.html"], ["articles/WebDevelopment/howtocreateadevelopmentserverusinghttpserver/index.html", "/articles/Python/how-to-create-a-development-server-using-http-server.html"] ] { build.route("301.tera", output, &{ let mut context: Context = Context::new(); context.insert("redirect", redirect); context }); }
// Build "/index.html" template build.route("index.tera", "index.html", &{ let mut context: Context = Context::new(); context.insert("articles", &build.postlist); context.insert("pagename", "index"); context.insert("image", "nasa-yZygONrUBe8-unsplash.jpg"); context.insert("artwork_credit", "Manuel Cosentino"); context });
// Build "/articles/index.html" template build.route("articles/index.tera", "articles/index.html", &build.empty_context);
// Build post templates for post in &build.postlist { build.route("articles/article.tera", &post.renderpath, &{ let mut context: Context = Context::new(); context.insert("articles", &build.postlist); context.insert("article", &post); context.insert("templaterendered", &build.render(&post.templatepath, &build.emptycontext)); context.insert("page_name", "article"); context }); } } ```
The source code included in this repository is distributed for free, under the MIT Licence. For the full license, see LICENSE.md.