|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## What this is |
| 6 | + |
| 7 | +interscript.org v2 — the Interscript website, rebuilt on Astro 7 (branch `astro-migration`). It replaces the legacy react-static site that still lives on the `main` branch — consult `main` (and `TODO.complete/`) as the reference for feature parity. Content claims must be factual: do not fabricate partner/authority/endorsement statements. |
| 8 | + |
| 9 | +## Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +npm run dev # dev server (localhost:4321; bumps port if taken — e2e uses 4322) |
| 13 | +npm run build # static build to dist/ |
| 14 | +npm run preview # serve the build |
| 15 | + |
| 16 | +npm run check # astro check (TypeScript across .astro/.ts/.vue) |
| 17 | +npm test # vitest run (unit tests in test/) |
| 18 | +npx vitest run test/site.test.ts # single test file |
| 19 | +npm run test:e2e # Playwright (e2e/); local runs need `npm run dev` on 4322 |
| 20 | +npm run lint # eslint |
| 21 | +npm run format # prettier --write . |
| 22 | +npm run generate:catalogue # regenerate src/data/maps-catalogue.json from .isc sources |
| 23 | +``` |
| 24 | + |
| 25 | +Dependency note: `interscript-ts` is a `file:` dependency on the sibling checkout `../interscript-ts`, and `npm run generate:catalogue` reads `../maps/maps/*.isc` — both sibling repos must exist locally. |
| 26 | + |
| 27 | +## Architecture |
| 28 | + |
| 29 | +- **Rendering**: Astro `output: "static"` + `@astrojs/node` adapter. Pages under `src/pages/` are prerendered by default; the real-time routes (`src/pages/api/{detect,systems,transliterate,transliterate/batch}.ts`) opt out with `export const prerender = false` and run `interscript-ts` server-side. |
| 30 | +- **Interactive islands**: Vue 3 (`@astrojs/vue`) for tools — `MapExplorer`, `CompareMode`, `BatchProcessor`, `DiffViewer`, `DetectPanel`, `MarcTool`, `SubtitlesProcessor`, etc. Static pages are plain `.astro` importing these islands. |
| 31 | +- **Map data**: ~289 compact `.isc` maps in `public/maps/`. The browsable catalogue `src/data/maps-catalogue.json` is generated by `scripts/generate-catalogue.mjs` (commit the regenerated file when maps change). |
| 32 | +- **Map loading strategies** (why two modules): browser runtimes use `src/scripts/map-strategies.ts` — ISC files first, compiled-JSON HTTP fallback only for `.iml` libraries (posix, unicode, var-Cyrl, var-kor) which have no ISC form. The SSR API routes use `src/lib/server-map-strategies.ts` — same order but ISC loads from the filesystem, no HTTP roundtrip. Keep both in sync. |
| 33 | +- **Transliteration worker**: `src/scripts/transliteration-worker.ts` runs interscript-ts off the main thread; `worker-client.ts` is the typed RPC client. Vite bundles the worker via `new Worker(new URL(...), { type: "module" })`. |
| 34 | +- **Design system**: single source of truth in `src/styles/global.css` — Tailwind 4 CSS-first `@theme` tokens (colors, fonts, type scale, spacing) plus component classes (`.btn`, `.card`, `.prose`, `.eyebrow`). All pages consume these tokens; don't hardcode hex values. `src/layouts/Base.astro` owns the header nav / drawer / footer and carries its scoped styles inline. |
| 35 | +- **Content**: AsciiDoc (`src/content/docs/`, `src/content/blog/`) loaded by `src/content/loaders/asciidoc.ts` (manual frontmatter parse + @asciidoctor/core), rendered into `.prose` wrappers. |
| 36 | +- **Theme**: light/dark via `data-theme` on `<html>`; tokens flip in `src/styles/global.css`. A service worker (`public/sw.js`) provides offline access. |
| 37 | + |
| 38 | +## Testing layout |
| 39 | + |
| 40 | +- `test/*.test.ts` — vitest + happy-dom; covers pages, components, catalogue integrity, API endpoints. |
| 41 | +- `e2e/*.spec.ts` — Playwright, Chromium only. In CI the config starts `npm run dev` itself; locally run the dev server on port 4322 first (config `baseURL`). |
| 42 | + |
| 43 | +## Conventions |
| 44 | + |
| 45 | +- Conventional Commits (`feat:`, `fix:`, `docs:`, …). All changes go through PRs to `main` (branch `astro-migration` is the active migration branch). |
| 46 | +- Lint: `eslint.config.mjs` (ESLint 10 flat config; TS + Astro + Vue). Prettier: `.prettierrc` (no semicolons, 100 cols, astro plugin), `.prettierignore` for generated/legacy paths. |
| 47 | +- **Astro whitespace trap:** Astro _trims_ the space at a text↔inline-tag line break — `Backed by\n<code>` renders as `byinterscript-ts`. `prettier-plugin-astro` reflows prose and will create such breaks; `test/site.test.ts` has a guard that fails on them. `prettier-ignore` comments corrupt `.astro` files — instead, hand-wrap the paragraph at text-only boundaries and add the file to `.prettierignore` (see `src/pages/compare.astro`). |
0 commit comments