2 releases
0.0.2 | Apr 5, 2024 |
---|---|
0.0.1 | Mar 3, 2024 |
#1132 in Text processing
116 downloads per month
Used in mockingbird
1.5MB
4.5K
SLoC
Harper + Mockingbird
This is a work-in-progress.
lib.rs
:
A toolkit for creating blazing fast static site generators.
Overview
Sketch is a library for creating really fast static site generators: programs that consume files and emit static HTML web sites and their assets. It does not enjoin any particular structure on source content nor operations on said content.
Internally, harper organizes content in a semi-hierarchy as follows:
+-------+
| Site |
+---+---+
|
+-----------------------------+--------------------------------+
| |
| +------------+ +------------+ +-------+ +-------+ |
| | Collection |... | Collection | | Asset |... | Asset | |
| +------------+ +------+-----+ +-------+ +-------+ |
| | |
| +----------------------+----------------------+ |
| | +--------+ +------------+ | |
| | | index? | | data group | | |
| | +--------+ +-----+------+ | |
| | +------+ +------+ +------+ | +------+ | |
| | | item |...| item | | data |...| data | | |
| | +------+ +------+ +------+ +------+ | |
| +---------------------------------------------+ |
+--------------------------------------------------------------+
In words, a site consists of:
-
Collections, consisting of:
-
Items, potentially sorted, one of which may be the index. Items are represented as a dictionary of string keys and JSON-like values. This dictionary is called the item's metadata. All item data is stored in its metadata. Metadata is transformed as item processing proceeds.
-
Data organized into data groups.
You can think of a collection as a directory and its contents partitioned into text content (items) and data, though it need not necessarily be organized in this fashion.
-
-
Assets
Assets, such as images and stylesheets, which are rendered according to a pipeline corresponding to the file's type.
Rendering
A site is typically rendered via the following set of operations:
- Files in a directory are read into collections.
- Items' metadata is transformed according to the SSG's liking. A typical
transformation might look like:
- Preamble metadata is read directly into the file's metadata.
- Item text is rendered as markdown into HTML and stored in a
content
metadata field. - The item is rendered into a template using the item's
metadata
as the templating context.
- Assets are transformed according to the SSG's liking.
- Fully transformed content is written to an output directory.
Dependencies
~20–30MB
~501K SLoC