# Loom docs — web page

A single-page documentation site for the Loom programming language, built as pure
static HTML + CSS + [Stick.js](../../README.md). Zero build step, zero
framework. Ready to deploy to Vercel as-is.

## Files

```
docs/web/
├── index.html   — the page (semantic HTML, Stick.js data attributes for interactivity)
├── style.css    — design tokens, dark mode default, prefers-reduced-motion safe
├── vercel.json  — cleanUrls + security headers + cache-control
└── README.md    — this file
```

## Local preview

Any static file server works. Examples:

```bash
# Python 3
cd docs/web && python -m http.server 4000
# → http://localhost:4000

# Node (one-off)
cd docs/web && npx serve -p 4000

# Vercel CLI (matches prod headers and rewrites)
cd docs/web && vercel dev
```

Open the printed URL in a browser. No build step, no watcher.

## Deploy to Vercel

### Option A — dashboard (Git integration)

1. Push the repo to GitHub / GitLab / Bitbucket.
2. Import it in the Vercel dashboard.
3. Set **Root Directory** to `docs/web`.
4. Leave **Framework Preset** as **Other** — Vercel auto-detects it as a static site.
5. Leave **Build Command** empty and **Output Directory** empty (Vercel serves the root directly).
6. Deploy.

Every push to the default branch triggers a production deploy; every PR gets a preview URL.

### Option B — Vercel CLI

From this directory:

```bash
cd docs/web
vercel               # first run: links or creates the project (interactive)
vercel deploy --prod # subsequent production deploys
```

The CLI uses `vercel.json` in this directory, so no extra flags are needed.

#### Troubleshooting: "No Next.js version detected"

If Vercel greets you with:

```
Error: No Next.js version detected. Make sure your package.json has "next"
in either "dependencies" or "devDependencies". Also check your Root Directory
setting matches the directory of your package.json file.
```

…it means the linked project in the Vercel dashboard was saved with the
**Framework Preset = Next.js**. This is sticky in the dashboard and overrides
local `vercel.json` on the initial detection pass for projects linked before the
static-site setting existed.

Fix (pick one):

**1. Re-link with the current `vercel.json` from scratch (easiest):**

```bash
cd docs/web
rm -rf .vercel              # unlink the stale project
vercel                      # link again — Vercel will now respect vercel.json
vercel deploy --prod
```

When it asks "Set up and deploy", say yes. When it asks "Link to existing
project?", say **no** and create a new one (or pick a different name). On the
fresh link, Vercel reads `vercel.json` with `"framework": null` and skips the
Next.js detection entirely.

**2. Change the preset in the dashboard:**

Go to `https://vercel.com/<your-team>/<project>/settings/general`,
find **Framework Preset**, set it to **Other**, and save. Then re-run
`vercel deploy --prod`.

**3. Delete the stale project and recreate it:**

Dashboard → project → Settings → Advanced → Delete Project. Then
`cd docs/web && vercel deploy --prod` — CLI will prompt to create a fresh
project that respects `vercel.json` from the start.

### Why `vercel.json` pins every build knob

The config in this directory explicitly sets:

```json
{
  "framework": null,
  "buildCommand": null,
  "installCommand": null,
  "outputDirectory": "."
}
```

- `framework: null` — equivalent to "Other" in the dashboard, disables all
  framework auto-detection (Next.js, Vite, etc.).
- `buildCommand: null` — no build step; Vercel serves the files as-is.
- `installCommand: null` — no `npm install` / dependency resolution.
- `outputDirectory: "."` — serve from the current directory (where
  `index.html` lives).

These four together tell Vercel "this is a pure static site — don't try to be
clever."

## Stick.js dependency

`index.html` loads Stick.js from a local file next to it:

```html
<script src="stick.js" defer></script>
```

**Drop your `stick.js` file into `docs/web/` before deploying.** Three ways to get it:

```bash
# A) From npm (if published)
cd docs/web && npm init -y && npm install stickjs
cp node_modules/stickjs/stick.js .
rm -rf node_modules package.json package-lock.json

# B) Copy from another project
cp ~/path/to/your/stick.js docs/web/stick.js

# C) Curl from your own CDN / GitHub raw
curl -fsSL https://your-cdn.example/stick.js -o docs/web/stick.js
```

### Graceful degradation

If `stick.js` is missing, the page **remains fully readable** — every section,
example, quickstart step, and footer link still shows. The only things that
stop working are the interactive enhancements:

- Codegen-target tabs (first panel remains visible)
- Copy-to-clipboard buttons
- Theme toggle
- Scroll-in reveal animations
- Pulse effect on pipeline stages
- Back-to-top button (stays hidden)

This is by design: content is always visible in the default CSS, and the
`.in-view` / `.active` / `.visible` classes are purely additive.

## What Stick.js powers on this page

Every interactive piece uses `data-stick` attributes — no custom JavaScript.

| Feature | Stick.js recipe |
| --- | --- |
| Theme toggle | `data-stick="click:toggle-class:light" data-stick-target="html"` |
| Codegen-target tabs | `data-stick-group="targets"` auto-hides sibling panels on `show` |
| Tab active state | `add-class:active` on self + `remove-class:active` on `siblings` |
| Copy code buttons | `data-stick="click:copy:{{#code-id.textContent}}"` + `animate:flash` on self |
| Pipeline stage pulse | `data-stick="click:animate:pulse"` (auto-removes on animationend) |
| Scroll-in reveal | `data-stick="intersect:add-class:in-view"` with `data-stick-once` |
| Back-to-top button | `data-stick="click:scroll-top"` + `scroll:toggle-class:visible` for show/hide |
| Brand link scroll-top | `data-stick="click:scroll-top"` |
| Skip link + focus mgmt | native HTML |

Find the full list in the [Stick.js docs](../../README.md).

## Security headers

`vercel.json` sets conservative security headers on every response:

- `X-Content-Type-Options: nosniff` — prevents MIME sniffing
- `Referrer-Policy: strict-origin-when-cross-origin` — trims referer leakage
- `X-Frame-Options: DENY` — blocks iframe embedding (clickjacking protection)

Plus `Cache-Control: public, max-age=3600, s-maxage=86400` on `/style.css` so the
edge caches aggressively while browsers revalidate hourly.

## License

Same as the rest of the Loom repo.
