Skip to content

brickfrog/lattice

 
 

Repository files navigation

lattice

lattice is a MoonBit static site generator built for the 2026 MoonBit Software Synthesis Challenge (SCC).

The project goal is structural integrity: content contract violations should fail the build, not appear later as runtime surprises.

Core Thesis

Content integrity is treated as a structural property of the build pipeline:

  • typed frontmatter schemas
  • validated wikilinks against a full site index
  • schema-enforced content collections and data files

In lattice, these are build-time failures:

  • missing required frontmatter fields
  • frontmatter type mismatches
  • broken wikilink targets
  • invalid template slots/data-slot paths
  • collection and data-schema configuration errors

Quick Start

Build the project:

moon build

Run a build with defaults (./content./dist, config at ./content/lattice.conf):

moon run cmd/main -- build

Run a build with explicit content/output directories:

moon run cmd/main -- build ./content ./dist

Run a build with config and collections overrides:

moon run cmd/main -- build ./content ./dist --config ./example/site.cfg --collections ./example/collections.cfg

Run structural checks only (no output writes):

moon run cmd/main -- check ./content ./dist

Run in polling watch mode for local development:

moon run cmd/main -- build ./content ./dist --watch

Adjust the polling interval if needed:

moon run cmd/main -- build ./content ./dist --watch --watch-interval 1000

Start the dev server with live reload:

moon run cmd/main -- serve ./content ./dist --port 4321

CLI

lattice uses subcommands powered by @clap:

lattice build   [content-dir] [output-dir] [options]   — build the site
lattice check   [content-dir] [output-dir] [options]   — validate/lint only
lattice serve   [content-dir] [output-dir] [options]   — dev server + live reload
Flag Subcommands Description
-c, --config <path> build, check, serve Override site config file
--collections <path> build, check, serve Override collections config file
--drafts build, serve Include draft posts
--watch build Rebuild on file changes with polling
--watch-interval <ms> build Polling interval (default: 500)
--force build Ignore incremental cache
-p, --port <N> serve HTTP port for dev server (default: 4321)

Defaults: content-dir./content, config → <content-dir>/lattice.conf, output-dirconfig.output_dir or ./dist.

Module Overview (src/)

  • assets: static file validation/copy with typed copy errors.
  • builder: two-pass orchestration (collect/index, then validate/render/emit).
  • collections: parser for typed collection and data-schema definitions.
  • config: site config parser with typed parse/validation errors.
  • data: typed data-file loader and schema validation for template data slots.
  • frontmatter: frontmatter parser to typed FrontmatterValue trees.
  • graph: shared typed page graph structures for downstream emitters.
  • highlight: syntax tokenization/highlighting for fenced code blocks.
  • html: HTML document emitters from typed metadata.
  • lint: typed violation model and formatting for check mode.
  • markdown: markdown parser/renderer with diagnostics.
  • pagination: typed pagination model for index-like pages.
  • rss: Atom feed rendering from typed page graph input.
  • schema: schema ADTs and frontmatter validation.
  • search: JSON search index rendering.
  • shortcode: shortcode parsing/rendering with typed params/errors.
  • sitemap: sitemap XML rendering.
  • slug: deterministic slug/path normalization helpers.
  • tags: typed tag extraction from frontmatter with automatic tag index and per-tag page generation.
  • template: template slot parser/renderer with typed slot and data-path checks.
  • wikilink: wikilink extraction/resolution against page index.

Example Site

The example/ directory is a compact feature demo site:

  • content: example/content/
  • templates: example/templates/
  • static assets: example/content/static/
  • config: example/site.cfg
  • notes: example/README.md

Run it with:

moon run cmd/main -- build ./example/content ./example/dist --config ./example/site.cfg

For local preview, start the dev server:

moon run cmd/main -- serve ./example/content ./example/dist --config ./example/site.cfg

Or pair --watch with a static file server such as simple-http-server:

simple-http-server ./dist

Build Instructions

From repo root:

moon build

About

A static site generator in MoonBit where structural violations are type errors, not runtime surprises. SCC 2026.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • MoonBit 89.1%
  • HTML 6.5%
  • CSS 2.2%
  • C 2.2%