@avelonjs/docs-site
@avelonjs/docs-site builds the Avelon documentation site from the same Markdown the repo already ships. The landing page is the Avelon map: vocabulary, then the commands and types you reach for. Fenced examples are syntax-colored. Reach for this package when you need to regenerate index.html after a README or catalog change.
Installation
From the repository root:
bun install --frozen-lockfile
Basic Usage
Build from the repository root:
bun run docs:build
The build writes the home page, package reference pages, and driver guide to packages/docs-site/dist/. bun run build from packages/docs-site writes to the same directory.
To preview the output from the repository root with Python 3:
python3 -m http.server 43242 --bind 127.0.0.1 --directory packages/docs-site/dist
Open http://127.0.0.1:43242.
To render to a custom directory, run this example from packages/docs-site:
import { resolve } from 'node:path'
import { buildSite } from '@avelonjs/docs-site'
await buildSite({
repoRoot: resolve('../..'),
outDir: '/tmp/avelon-docs',
})
Landing page
The first page is the map of the framework. A vocabulary table names the Avelon words. Catalog sections then list what you want, what you reach for, and a one-line note. Package READMEs are not the homepage; they hang off /packages.
Presentation
The static renderer and interactive docs share the Avelon wordmark, five-layer poster geometry, semantic tokens, and appearance behavior. Static layout, typography, and focus rules apply under body.docs-static, so interactive renderers retain their own stylesheet cascade. The initial appearance is system. It follows the operating-system preference until a reader selects light or dark; the selected appearance is stored under avelon-docs-appearance. The root element exposes the selected appearance through data-appearance and the resolved result through data-theme.
import { resolveDocsTheme } from '@avelonjs/docs-site'
const theme = resolveDocsTheme('system', true)
Browser components import presentation data from the server-free subpath:
import { AVELON_POSTER_LAYERS, type DocsAppearance } from '@avelonjs/docs-site/presentation'
const appearance: DocsAppearance = 'system'
const firstLayer = AVELON_POSTER_LAYERS[0]
The static stylesheet requests no remote font assets. It uses installed local copies of Inter and IBM Plex Mono when present, then falls back to the system sans and monospace stacks. The Next docs app bundles both families through next/font.
Method Reference
| Method / export | Signature | Description |
|---|---|---|
CATALOG | readonly CatalogSection[] | Grouped jobs and Avelon names rendered as the landing tables. |
CatalogRow | interface | term, youReachFor, and notes. |
CatalogSection | interface | title plus rows. |
VOCABULARY | readonly VocabularyEntry[] | Named Avelon words and one-line jobs. |
VocabularyEntry | interface | name and job. |
VocabularyLabel | interface | Plain primary label and Avelon aka name. |
guideLabelFor | (slug: string) => VocabularyLabel | undefined | Looks up a guide label by document slug. |
packageRoleFor | (name: string) => VocabularyLabel | undefined | Looks up a package role by unscoped name. |
buildSite | (options: BuildSiteOptions) => Promise<BuildSiteResult> | Writes index.html and derived pages. |
buildFromRepo | () => Promise<BuildSiteResult> | Builds into this package's dist/ from the repo root. |
BuildSiteOptions | interface | repoRoot and outDir. |
BuildSiteResult | interface | landingPage and pages. |
DocsAppearance | 'system' | 'light' | 'dark' | Reader preference before system resolution. |
DocsTheme | 'light' | 'dark' | Resolved visual theme. |
DOCS_APPEARANCE_STORAGE_KEY | 'avelon-docs-appearance' | Browser storage key for the appearance preference. |
DOCS_APPEARANCE_SCRIPT | string | Pre-paint script that applies and persists appearance. |
resolveDocsTheme | (appearance: DocsAppearance, systemDark: boolean) => DocsTheme | Resolves an appearance preference. |
DOCS_PRESENTATION_CSS | string | Shared semantic CSS for documentation renderers. |
AVELON_WORDMARK_PATHS | readonly string[] | SVG paths for the Avelon wordmark. |
AvelonPosterLayer | interface | A giant-A poster layer with offset and path. |
AVELON_POSTER_LAYERS | readonly AvelonPosterLayer[] | SVG paths for the five-layer poster. |
markdownToHtml | (source: string) => string | Converts house-style Markdown to HTML. Repeated headings get distinct ids. |
headingId | (text: string) => string | Stable slug for a heading, used as the HTML id. |
escapeHtml | (value: string) => string | Escapes text for HTML. |
Testing
Run these examples and commands from packages/docs-site.
import { mkdtemp } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join, resolve } from 'node:path'
import { buildSite } from '@avelonjs/docs-site'
const outDir = await mkdtemp(join(tmpdir(), 'avelon-docs-'))
const result = await buildSite({ repoRoot: resolve('../..'), outDir })
await Bun.file(result.landingPage).text()
bun test
bun run typecheck
bun ../../packages/cli/src/bin.ts docs:check