orz-site
v0.4.0
Published
A folder of orz texts (Markdown documents, slide decks, paged documents) as a static site of self-editing pages — for GitHub Pages and any static host.
Maintainers
Readme
orz-site
A folder of orz texts as a static site. orz-site turns a folder of
text twins — Markdown documents (*.md), slide decks (*.slides.md), paged
documents (*.paged.md) — and their assets into a site of self-editing
pages, ready for GitHub Pages or any static host. The repository keeps only
text; the build assembles every page with the exact carrier versions the
site pins.
course/ _site/
orz-site.json index.html generated contents page
index.md ──► index.md.html index.md
lessons/01-cells.md lessons/01-cells.md.html lessons/01-cells.md
slides/week1.slides.md slides/week1.slides.html slides/week1.slides.md
handouts/lab.paged.md handouts/lab.paged.html handouts/lab.paged.md
img/cell.svg img/cell.svg copied byte for byte
shared/policies.md (excluded) sitemap.xml .nojekyll orz-site-manifest.json- Every page is a carrier file: the same bytes
orz-mdhtml,orz-slidesororz-pagedassemble, so each page can be read, edited and saved by a reader, and verify.html reproduces it byte for byte. - Links between texts just work:
[Week 1](../slides/week1.slides.md)in a text opensweek1.slides.htmlon the site (the kit's twin-link rule, applied when the page renders); dead links between texts stop the build. - Includes are resolved at build time (
{{md shared/policies.md}}, or a URL on the site's own host or an allowed host) and stored in each page. - Deterministic: the same texts, config and versions give the same bytes — no timestamps, sorted output.
Status: 0.4.0 (front pages from blocks and four templates, and a credit line; 0.3.0 added nav, 0.2.0 readerCopy). Layer: above the carriers
(orz-mdhtml, orz-slides, orz-paged) and the kit (orz-markdown); no
carrier or kit module knows orz-site (family RULES §1). Design:
spec/site.md (family contract FC-20).
Install
npm install --save-dev orz-site [email protected] [email protected] [email protected]The carriers (and the kit, orz-markdown) are peer dependencies: the
site's orz-site.json pins the exact carrier versions, and the build refuses
an installed carrier whose version differs (shell-mismatch). Install only
the kinds the site uses. Node ≥ 20.16.
CLI
orz-site build [dir] [-o out] [--base-url url] [--offline] [--incremental] [--json]
orz-site check [dir] [--offline] [--json]
orz-site init [dir] [--github [--update]] [--json]| Command | What it does |
|---|---|
| build | Assembles every text of dir (default .) into out (default dir/_site, excluded from the input). Writes into a temporary sibling folder and renames it over out; an existing out that is not an orz-site output is refused (out-not-site). --base-url overrides baseUrl (route A passes the Pages URL). --offline fetches nothing. --incremental reuses the pages of out whose build key is unchanged (the result equals a full build). |
| check | Everything build checks, writing nothing. Also red for a missing orz-site.json, a kind used without a pin, and a workflow whose install line drifts from the pins (workflow-drift). |
| init | Writes orz-site.json with the installed carriers as pins and every default. --github also writes .github/workflows/orz-site.yml (route A). An existing file is never overwritten (exists); --github --update rewrites a workflow that differs from the template only in its version lines. |
Exit status: 0 done (warnings allowed), 1 refused, 2 usage — as the
carriers. With --json, one object on stdout:
{ "ok": true, "command": "build", "out": "/abs/_site", "documents": 7, "assets": 2, "outputs": 20, "errors": [], "warnings": [] }
{ "ok": false, "command": "build", "error": "refused: 1 error (first: …)", "reason": "missing-link", "next": { "command": "init", "args": [] }, "exitCode": 1, "errors": [ … ], "warnings": [ … ] }reason is the first error's code; next (when there is one) is a command
to run verbatim — orz-site <command> <args>, or <tool> <command> <args>
when it names another program ({ "tool": "npm", "command": "install",
"args": ["[email protected]"] }, { "tool": "orz-slides", "command":
"upgrade", "args": ["slides/old.slides.md"] }). Never --force. Findings
are { code, message, path?, line?, target?, next? }, sorted with the
site-level ones (the config) first, then by path, line and code. The codes
are listed in spec/site.md §7.2; 0.1 adds no-carrier,
no-pin and unreadable.
Config: orz-site.json
JSON at the site root. Reference: the JSON Schema
schema/site-1.json (published in the package:
"$schema": "https://cdn.jsdelivr.net/npm/[email protected]/schema/site-1.json")
and spec/site.md §3. Unknown keys are errors (a misspelt
exlude must not publish drafts). format is the config format (1),
independent of the package version.
{
"$schema": "https://cdn.jsdelivr.net/npm/[email protected]/schema/site-1.json",
"format": 1,
"carriers": { "md": "1.4.0", "slides": "1.4.0", "paged": "1.4.0" },
"delivery": "cdn",
"inline": ["handouts/**"],
"naming": "family",
"baseUrl": "https://owner.github.io/course/",
"includes": { "allowedHosts": [], "network": true, "missing": "error" },
"links": { "missing": "error" },
"exclude": ["drafts/", "shared/"],
"texts": true,
"index": { "mode": "auto", "title": "Course", "theme": null, "lang": "en" },
"sitemap": true,
"notFound": "404.md"
}| Key | Meaning | Default |
|---|---|---|
| format | config format version | required |
| carriers | exact version per kind (md → orz-mdhtml, slides → orz-slides, paged → orz-paged) | check requires a pin per kind used |
| delivery | cdn (engine from jsDelivr; right for sites) or inline | cdn |
| inline | globs of documents assembled inline anyway | [] |
| naming | "family" (x.md → x.md.html, x.slides.md → x.slides.html, x.paged.md → x.paged.html), or per-kind templates such as { "md": "{stem}.html" } ({stem} once, otherwise only A-Z a-z 0-9 . _ -, ending in .html, same folder; a kind left out keeps the family name). A template naming needs carriers 1.1.0 or later, which carry it into each page (twinLinks), so the rendered links, the editor preview and verify.html agree; older pins are refused (naming-unsupported) | "family" |
| readerCopy | (0.2) pages published for readers: true — a page's editor, opened from the site, says edits can't be saved to the website and its Save reads "Download a copy"; { "notice": "…" } — the same with your own words (1–300 characters). Needs carriers 1.3.0 or later (reader-copy-unsupported otherwise) | false |
| nav | (0.3) the site's navigation: { "title": "…", "home": "index.md", "pages": ["unit1/notes.md", "unit1/notes.slides.md", …], "labels": { "unit1/notes.md": "1 · Notes" } } — every page shows a slim bar outside its text (the title linking home, Previous / Next in pages order; never printed). home defaults to the generated index; a label defaults to the document's title; a page not in pages gets the title and home only; a listed path with no page is a warning (nav-missing). Needs carriers 1.4.0 or later (nav-unsupported otherwise) | null |
| baseUrl | the site's URL, ending in / (sitemap, own-host includes, root-relative warnings) | none |
| includes | allowedHosts (https hosts that may be fetched), network, missing (error/warn) | [], true, error |
| links.missing | a link to a text that is not built: error or warn | error |
| exclude | globs neither built nor published (still readable as file includes) | [] |
| texts | also publish each text twin as is | true |
| index | the generated contents page: mode (auto/on/off), title, theme, lang | auto, "Contents", default theme, en |
| index.template | (0.4, unreleased) a front page instead of the generated contents page: "classic", "cards", "sidebar" or "compact" — plain static HTML and CSS (no script), in the colours and fonts of the site's theme (index.theme, else the theme of the page the first chapter's title opens), fonts self-hosted in orz-site-fonts/ (woff2 + SIL OFL), no outside request. See Front page | null (the generated page, byte for byte as before) |
| index.blocks | (0.4) the front page's blocks, in order: { "id": …, "on"?: false, …options } with ids header, semester, chapters (kinds, labels), about, description, instructor, licence, updated, announcement (each but header/updated takes heading). Another id is kept and ignored (a newer host may add blocks) | header, semester, chapters, description, about, instructor, licence, updated (announcement off) |
| index.data | (0.4) what the host knows: title, subtitle, level, term, description, about { href, opening? }, instructor { name, title?, affiliation?, bio? }, semester [{ label, href, note? }], announcement { text, href? }, licence { id?, label, href? }, citation, adapt { href, label? }, updated (YYYY-MM-DD), chapters [{ title, pages }] — plain text, bounded, escaped; hrefs relative (a text path becomes its page) or https | null |
| credit | (0.4) { "text": "Made with …", "href": "https://…", "logo"?: "orz" }: a quiet last line on the front page (and the generated contents page); the words are the link's name, the orz mark is decorative | null (no credit) |
| sitemap | write sitemap.xml (needs baseUrl) | true |
| notFound | a root text whose page is written as 404.html | null |
Globs: * (not /), ** (any depth), ?; a pattern ending in / is the
folder and everything under it. Always excluded: any path segment starting
with ., node_modules/, names ending in ~ (carrier backups), the config
and the output folder.
What the build does
- Kind by file name (FC-18):
*.slides.md,*.paged.md, other*.md; everything else is an asset, copied byte for byte. A committed assembled file is copied with the warningassembled-input(andlegacy-filefor a 0.x one, with the upgrade command asnext). - Each text is read by its own carrier (
readDocument); a lint error refuses it (invalid-text) — so a 0.x deck text is refused withorz-slides upgrade <path>asnext. An empty text (no body) is skipped withempty-text. - Includes resolve into each page's
#orz-includesrecord: file targets from the site (relative to the text, inside the root; excluded partials included); URLs on the site's own host from the site's files, never the network; URLs on anallowedHostshost fetched once per build (https only, no redirects, 15 s, 5 000 000 characters, nested up to depth 3), their SHA-256 in the manifest; anything elseinclude-host. Missing or refused includes are errors unlessincludes.missingiswarn. - Links between texts are checked with the kit's parser: a link to a text
that is not built (missing, excluded, empty, outside the root) is
missing-link(an error by default); a missing asset, a raw-HTML<a href="x.md">, an upper-caseX.MDand a root-relative link on a project site are warnings. Fragments are not checked in 0.1. - Collisions are refused, never resolved: two parties wanting one output
path (
name-collision), or paths differing only in letter case (case-collision); every party is named. - The index (
index.mode: auto, when no page or asset isindex.html) is an orzmddocument generated as text — titles, kinds, dates and descriptions of the built documents, grouped by folder — and assembled by the pinned orz-mdhtml; its text is in the manifest (and published asindex.mdwhen that name is free). - The manifest
orz-site-manifest.json(published): which text became which page with which shell, the includes and their hashes, theuids, what was skipped and why, and each page's build key (for--incremental).
Library
import { buildSite } from 'orz-site'; // the browser-safe core
import { buildFolder, readSiteFolder, loadCarriers, writeSite, initSite } from 'orz-site/node';
const { files, errors } = readSiteFolder('course');
const { carriers } = await loadCarriers();
const result = await buildSite(files, config, { carriers, baseUrl: 'https://owner.github.io/course/' });
// → { ok, files: Map<path, bytes>, manifest, report }; a refused build has no files
if (result.ok) writeSite('_site', result);buildSite(files, config, env) takes a Map<sitePath, Uint8Array> and the
parsed config, and reads nothing else: no clock, no environment, no files.
env.carriers are the carrier modules (kind, version, formats,
assemble, extract, readDocument; from 1.1 also includeTargets,
linkTargets); env.fetch the transport for network includes;
env.previous a previous manifest and output for an incremental build. The
include and link targets come from the kit's parser (includeTargets,
linkTargets of orz-markdown/carrier, re-exported from the main entry):
the carrier's own when it has them, else the kit's — browser-safe, so a
build in the browser reads the same targets as one in Node.
Publishing
Route A — GitHub Actions and Pages (default). orz-site init --github
writes .github/workflows/orz-site.yml: on each push to main it installs
orz-site and the pinned carriers (exact versions, into $RUNNER_TEMP, never
committed), builds with the Pages URL as --base-url, and deploys the
output as a Pages artifact. Set the repository's Pages source to GitHub
Actions. Actions are pinned by major tag. A carrier update is: edit the pin
in orz-site.json, run orz-site init --github --update, commit;
orz-site check reports a workflow that does not match the pins.
Route B — an app builds in the browser and commits. The core is the same
code in a browser: the app reads the site's files, imports each pinned
orz-<x>-browser ESM from jsDelivr, calls buildSite, and commits
result.files as one commit to a publishing branch (Pages source "Deploy
from a branch"; .nojekyll is always written). Claim S.2: the course
fixture built this way in Chrome, with the -browser ES modules of the
pinned versions, equals the Node build byte for byte.
Front page (0.4)
With index.template, index.html is a front page built from blocks
(owner decisions 2026-11-28). Chapters and This semester come first in
every template, right after a short header — on the first phone screen.
- Chapters — from
index.data.chapterswhen the host gives them, else orz-site groups the pages that share a file stem across folders (study-guide/gases.md,slides/gases.slides.md), innav.pagesorder (else by path). A page kind is the folder a page sits in; the chapters block listskinds(default: the first two the site lists), and a chapter's title opens its first listed kind; the others follow as links.labelsnames the kinds (default: the folder, humanized). - About / description — the description wins; else the About page's
opening (
about.opening, else that page's headerdescription). The about block shows only while its page is in the built site. - Announcement — off by default; list
{ "id": "announcement" }. - A data link to a page not in the site is left out with a
missing-linkwarning; the front page never stops a build. - Templates: Classic (one centred column, prints as a two-column handout), Cards (a semester strip and chapter cards), Sidebar (chapters in a sticky side column; a jump bar on phones), Compact (a dense table; a ~20-chapter course prints on one page).
The front page is plain HTML: it is not an orz file (no editor, no nav bar
of its own); the pages' nav bars link home to it. The credit line appears on
the front page only: the carriers' read view has no site footer
(FC-18 §8.2 siteNav takes only title, home, previous, next).
Limits of 0.2
- A template
namingneeds every carrier the site uses at 1.1.0 or later (naming-unsupportedotherwise): a page's links are rewritten by the kit when the page renders, so the site's names must travel in the file (the kit'stwinLinks, orz-markdown 2.5.0). - The 404 page's relative links resolve from the site root only.
- Route B (an app that builds in the browser and commits) is the core's job
only up to
result.files: committing is the app's.
Development
npm ci
npm test # vitest: main (unit, core, CLI) then chrome (real Chrome, skipped without it)
npm run test:fast # the no-Chrome lane
npm run build # dist/Claims and their tests: notes/CLAIMS.md. The fixture
course is fixtures/course/. Release: the family's gate and green-run stamp
(scripts/release-check.ts, scripts/test-release.ts, copied from the
family root by scripts/tooling-sync.ts; facts in release.config.json).
License
MIT © Yu Wang
