User Guide
Learn the end-to-end authoring, compilation, form-handling, and verification workflow for building sites with SWS.
Declarative Site Authoring
SWS separates structured content and design tokens from generated output. Never hand-edit generated files in core/public/ or sites/*/public/; instead, update the structured source data and re-run the deterministic compiler.
- Structured inputs: Core sites compile from declarative JSON IR (
sws-ir), and vertical packs supply validated domain schemas (for example,venue.jsoninpacks/hospitality). - Deterministic output: Running the renderer with identical inputs always produces byte-identical HTML, CSS,
robots.txt,sitemap.xml, and404.html. - Drift detection in CI: Use
npm run render:check(andnpm run sites:checkfor the landing/docs sites) to assert that committed static output matches its source inputs without rewriting files.
Design Tokens & Contrast Safety
SWS generates lean, self-hosted stylesheets with zero external font or CSS CDN dependencies. Every foreground/background pair is checked against WCAG 2.2 Level AA thresholds (at least 4.5:1 for body copy and 3:1 for large text and interactive UI borders).
To keep static sites under strict Content Security Policy (style-src 'self'), avoid inline style attributes and inline <script> blocks.
Progressive-Enhancement Forms
Forms in SWS published sites work even when JavaScript is disabled:
- Baseline HTML: Every form submits standard
application/x-www-form-urlencodedPOST requests to/api/inquireor/api/newsletter. - Accessible semantics: Inputs pair explicit
<label for="...">elements,aria-describedbyerror hints, and anaria-livestatus region for feedback. - Progressive JS island: A lightweight script enhances submissions with
fetchand inline status updates without replacing native browser form semantics. - Server-side enforcement: The Rust edge Worker enforces a 16 KB streaming request body cap, honeypot screening, Cloudflare Turnstile verification, and bound-parameter D1 inserts.
CAN-SPAM Newsletter Consent
Newsletter forms render an explicit, unchecked consent checkbox by default. The Worker stamps consent_timestamp (ISO-8601 UTC) and source_route in D1, and refuses to silently re-subscribe addresses marked unsubscribed or bounced.
Workspace Scripts Reference
| Command | Purpose |
|---|---|
npm run render |
Render the showcase fixture into core/public/ |
npm run render:check |
Verify core/public/ matches source inputs without writing |
npm run sites:build |
Build both static sites (sites/landing/public and sites/docs/public) |
npm run sites:check |
Verify static site output is up to date |
npm run check:headers |
Assert static parity between _headers and Rust SECURITY_HEADERS |
npm run test:unit |
Run Node unit tests (tests/unit/*.test.mjs) |
npm run verify |
Run all fast checks (render, sites, lint, header parity, Rust tests, cargo deny) |
npm run test:a11y |
Run Playwright WCAG 2.2 AA (axe-core) and header E2E specs |
npm run lhci |
Run Lighthouse CI (requires accessibility score 1.0) |