Files
site/.agent/memories/port-site-to-astro.md
T

103 lines
4.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Port `site` to Astro (`site-2`)
Date: 2026-11-01
## Task
`site/` is a static build output. Port it 1:1 to Astro in `site-2/`.
## What `site/` actually contains
The current site is a hand-written static site with a dark "jewel" design:
- `index.html` — homepage
- `project/index.html` — "The Project" page
- `devices/index.html` — generated device cards (from `devices/status.json`)
- `assets/peacock-head.svg`, `assets/peacock-full.svg` — inlined at runtime
- `logo-mark-dark.png` — favicon
- `scripts/gen-devices.py` + `.github/workflows/devices.yml` — device pipeline
- `vercel.json` — static hosting config
It also contains **stale leftovers from an older Next.js export** (light
"builder design language" theme, branch `origin/site-redesign-light`):
`404.html`, `404/`, `_not-found/`, `_next/`, `index.txt`, `__next*.txt`,
`assets/site.css`, `assets/site.js`. Nothing in the current pages references
them (only `404.html` references `_next`). These were intentionally **not**
ported.
Git context: HEAD on `master` is commit `52064e2` ("Rework homepage copy …"),
which is the current dark site. The Next.js files date from commits
`46e21d5`/`2679833`/`211fe75`.
## Astro structure
```
site-2/
astro.config.mjs static, build.format 'directory'
public/ favicon, devices/status.json, devices/img/
src/
assets/peacock-*.svg imported with ?raw and inlined at build time
components/
Header.astro homeHref prop (index uses "#", others "/")
Footer.astro
Mark.astro strips <?xml?>, fill:#xxx -> fill:currentColor
IridescentDefs.astro hidden SVG with the #irid gradient
layouts/Base.astro head/meta/fonts, ambient/grain, page wrapper, shared script
pages/
index.astro
project.astro
devices.astro renders from public/devices/status.json at build time
404.astro
scripts/site.js reveals + spine (mark inlining removed)
styles/global.css exact original <style> block from index.html
scripts/gen-devices.py trimmed: no longer emits devices/index.html
.github/workflows/devices.yml commits public/devices/ instead of devices/
```
## Decisions
1. **Inline the peacock SVGs at build time** (`?raw` + regex) instead of the
original runtime `fetch()`. Same DOM/appearance, no network round-trip and
no flash. `data-mark` attributes are gone because they are no longer needed.
2. **Shared CSS as a stylesheet.** The original inlined the same `<style>` on
every page. Astro bundles it to `/_astro/Base.*.css`; rule set is identical
(88 selectors, minifier only rewrites `::after`→`:after` and media query
range syntax).
3. **Devices page is data-driven at build time** rather than generated HTML.
`devices.astro` reads `public/devices/status.json`, reproduces the Python
generator's grouping/platform/image/search logic exactly. The Python script
now only writes `status.json`, images and the wiki.
4. **404 is new** (in the dark design). The original `404.html` was the stale
light Next.js page; porting it would have preserved a design bug.
5. **Keep URLs identical**: `/`, `/project`, `/devices`, `/404.html`; external
links unchanged; nav unchanged (devices is still not in the nav).
6. `assets/site.css`/`site.js` were dropped because no current page uses them.
## Verification performed
- **Structure/text**: custom HTML parser diff (ignoring style/script/SVG/CSS
link/data-mark) → `IDENTICAL STRUCTURE/TEXT` for index, project, devices
(268/245/225 nodes).
- **CSS**: selector-set comparison → identical (88 global, 19 devices).
- **Layout**: Puppeteer `getBoundingClientRect` for every element at 1440×900,
fonts awaited → 0 meaningful differences. (Found and fixed one real bug: an
Astro HTML-compression whitespace drop before the "wiki" link on /devices.)
- **Pixels**: full-page screenshots of both sites, `prefers-reduced-motion`,
same fonts → identical dimensions; zero pixels differ by more than 1%.
- **Interactions**: reveals, spine fill (100% at bottom), mark paths, device
search filtering, no-result message, project door count, 404 title; no
console/page errors.
- Generator functions (`by_brand`, `platform`, `support_items`, `matrix_md`,
`index_md`) exercised against the real `status.json`.
## Follow-ups / notes
- `public/devices/status.json` is the single source for the devices page. The
CI script writes it there (Astro copies `public/` as-is).
- `site/` still has its own `.git` and is not tracked by this repo root (the
root is not a git repo). Do not edit `site/` as part of the port.
- If the design changes upstream in `site/`, re-extract the `<style>` block to
`src/styles/global.css` and re-check page markup.
- Screenshot/rect comparison scripts lived in `/tmp/opencode` and are not
committed.