2 releases

0.0.2 Apr 5, 2024
0.0.1 Mar 3, 2024

#414 in Data structures

Download history 152/week @ 2024-02-27 45/week @ 2024-03-05 7/week @ 2024-03-12 4/week @ 2024-03-26 127/week @ 2024-04-02

139 downloads per month
Used in mockingbird

MIT/Apache

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:

  1. Files in a directory are read into collections.
  2. 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.
  3. Assets are transformed according to the SSG's liking.
  4. Fully transformed content is written to an output directory.

Dependencies

~19–28MB
~443K SLoC