Fabricate
Introducing Fabricate, a Clojure library for making static websites, using Clojure.
Fabricate gives you something other tools don't: the power to evaluate Clojure code to generate the contents of a page. The “using Clojure” part of that first sentence contains the core idea: Fabricate is built on the idea that you should be able to use Clojure to generate as much (or little) of your website as is necessary.
What does that look like?
Examples
(let [s "output"]
(list [:hr]
[:strong (format "a form evaluated and displayed with its %s" s)]))
a form evaluated and displayed with its output
Fabricate gives you a template that allows you to mix regular text and Clojure expressions. Hiccup forms returned by those expressions become HTML elements when Fabricate generates the page.
Fabricate also gives you an API that can generate a website using 3 core functions.
A simple API
(-> {}
api/plan!
api/assemble
api/construct!)
This API, while straightforward enough to quickly get started with, does not constrain what you can do with Fabricate. You can extend Fabricate to new markup formats or other methods of generating pages. If you use Clerk for some things and markdown for others, Fabricate can flexibly accommodate all of them with a unified API.
Simple things should be simple. Complex things should be possible.
(require '[my-generation-code :refer [generate]])
(defmethod api/build [:my/format :hiccup]
[entry options]
(generate entry))
Documentation
Tutorials
These guides will get you up and running with Fabricate, so you can use it as a writing and creative tool. Hopefully you find them useful.
Tutorial 1: Using Fabricate to add documentation to an existing Clojure project
This first tutorial allows you to use Fabricate to document a project or library you've built.
Tutorial 2: Using Fabricate to create a website
🏗️ To be published.
In the second tutorial, you will learn how to publish all the pages you create using Fabricate as a website.
How-to guides
Supporting Fabricate in Emacs
Consult this guide to add support for Fabricate's templates to Emacs.
Further guides (to be published 🏗.)
- Visualizing data using inline SVGs
- Syncing your website with a web server
- Publishing your website on Netlify
Reference
Background Information
- Organizing Computation With Finite Schema Machines
A description of how Fabricate arranges the sequence of transformations to get a HTML page from an input template.
Namespaces
The namespace descriptions, automatically generated from the namespace forms, introduce the functionality that fabricate assembles to create pages.
site.
fabricate. api Fabricate's public API. This contains the core set of operations that Fabricate uses to produce a website from input files.
site.
fabricate. prototype. schema Utility namespace for working with malli schemas, including a default registry and predicates used across Fabricate's implementation.
site.
fabricate. prototype. html Namespace for creating HTML forms using Hiccup data structures and for verifying their structural correctness using malli schemas. The schemas in this namespace implement a non-interactive subset of the MDN HTML spec.
site.
fabricate. prototype. read Parsing + evaluation utilities for embedded Clojure forms. The functions in this namespace split the text into a sequence of Hiccup forms and embedded expressions, which is then traversed again to evaluate it, embedding (or not) the results of those expressions within the Hiccup document.
site.
fabricate. prototype. read. grammar Instaparse grammar for Fabricate's page templates.
site.
fabricate. prototype. hiccup Functions for transforming Hiccup elements after processing.
site.
fabricate. prototype. source. clojure Fabricate namespace defining methods for turning Clojure namespaces into Hiccup documents