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.

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:

  1. Baseline HTML: Every form submits standard application/x-www-form-urlencoded POST requests to /api/inquire or /api/newsletter.
  2. Accessible semantics: Inputs pair explicit <label for="..."> elements, aria-describedby error hints, and an aria-live status region for feedback.
  3. Progressive JS island: A lightweight script enhances submissions with fetch and inline status updates without replacing native browser form semantics.
  4. 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)