The NiiVue documentation site: Markdown guides with live demos, plus a
gallery of the example pages and demo apps. Built with
Astro and Starlight
and deployed to https://niivue.com/docs/ by .github/build-pages.sh.
bunx nx dev docs-site # dev server
bunx nx build docs-site # static build in apps/docs/distsrc/content/docs/guide/*.mdx: the guides. Each live demo is a module insrc/demosthat receives a canvas and returns the viewer;<Demo name="…" />runs it and shows its source. Link between pages with root-relative URLs (/guide/meshes/);astro.config.tsadds the base path.src/lib/gallery.ts: builds the repository knowledge graph (bun run graph:build) and turns each card inpackages/niivue/examples/index.htmland.github/pages/index.htmlinto a gallery entry, so adding a card there adds it to the gallery. The code shown for an example is its inline script plus the local modules the graph links it to.src/content.config.tsloads it as thegallerycollection, andsrc/pages/gallery/renders it.src/lib/markdown.ts: each guide as Markdown at<page>/index.md(with<Demo>written out as its code), joined into/llms-full.txtand indexed by/llms.txtin the order ofsrc/sidebar.ts, following llmstxt.org. Guides need adescription.src/pages/index.astro: the home page.src/components/Hero.astroandSiteTitle.astrooverride Starlight's hero and header title;PageTitle.astroputs the gallery search beside the title.scripts/screenshots.ts(bunx nx screenshots docs-site [-- slug...]): captures gallery thumbnails, running any per-demoPREPAREsteps first. SetDOCS_EXAMPLES_BASEto the server root (http://localhost:5273/), not/examples/.
Environment variables:
| Variable | Default | Purpose |
|---|---|---|
DOCS_BASE_URL |
/ |
URL prefix of the site |
DOCS_EXAMPLES_BASE |
https://niivue.com/ |
where demos fetch images and the gallery embeds example pages |