# OK SSG demo

This folder contains the demo page used by the new hook-based SSG server.

## What it demonstrates

- server-side prerender captures the original init target into a sibling `<template>`
- prerendered root is marked with SSG metadata
- SSG behavior is provided through generic init hooks, not SSG-specific core branches
- the SSG server injects a bootstrap only for interactive output
- interactive client init mounts a clean sidecar root from the preserved template source, then replaces the prerendered node
- static output strips preserved remount metadata and installs a tiny SSG `skipInit` hook if the page script still runs

## Files

- `index.html` — source HTML for the demo
- `build.js` — prerenders `index.html` into both `index.ssg.html` and `index.static.html` through the shared capability-owned SSG render pipeline
- `client.js` — plain browser bootstrap (`OK()`), relying on injected SSG hooks when served by the SSG server
- `smoke.js` — JSDOM smoke test for server prerender + client swap
- `index.context.js` — context factory used by the SSG render pipeline
- `app.ok.js` — demo component

## Run

Build the prerendered page:

```powershell
npm run ssg:build
```

Run the smoke test:

```powershell
npm run ssg:smoke
npm run ssg:server:smoke
```

Start the actual SSG server:

```powershell
npm run ssg:serve
```

Then open:

```text
http://localhost:3002/dev/ssg/index.html
```

For static mode, open:

```text
http://localhost:3002/dev/ssg/index.html?ok-ssg-mode=static
```

You can also inspect the prerendered artifacts generated by the shared renderer:

```powershell
npm run ssg:build
```

- `index.ssg.html` — interactive artifact expecting the SSG bootstrap route
- `index.static.html` — cleaned static artifact with no remount bootstrap

## Notes

- The smart remount path is intended for a dedicated app root like `#app`, not `document.body`.
- During interactive remount, the runtime only toggles predictable timing attributes (`data-ok-ssg-remount-root` / `data-ok-ssg-remounting`). It does not enforce any animation policy.
- The demo marks static-only elements with `data-ok-static="omit"`, so `index.static.html` drops them entirely while preserving unmarked markup by default.
- The shared SSG implementation now lives under `dev/dev-server/capabilities/ssg/`; `dev/dev-server/ssg-server/` is just the standalone server entrypoint and compatibility surface.
- Component styles currently still come from the normal runtime path; DOM ownership/adoption of SSR-inserted styles can be added later.
- The interactive `index.ssg.html` expects the SSG bootstrap route (`/__ok_ssg__/bootstrap.js`), so the real `ssg:serve` server is the intended way to load it in a browser.

