ts-maps docs
On this page 3
The source of the docs site, built with
BunPress. The sidebar and nav are in
.config/bunpress.ts at the repo root.
Running it
From the repo root:
bun run dev:docs # dev server with hot reload
bun run build:docs # static build into dist/.bunpress
bun run preview:docs # serve the built docs
bun run build:site # build:docs, then the playground into dist/.bunpress/playground
build:docs runs four steps:
scripts/build-example-gallery.tswritesexamples/index.md.scripts/build-demo-pages.tswritesdemos/.- BunPress builds the site.
scripts/fix-doc-links.tsrewrites links between pages for the built site (see below).
The examples' live frames and the playground demos load from /playground/,
which build:playground builds; build:site runs it after build:docs.
Layout
index.md: the home page (BunPress home layout).intro.md,install.md: what ts-maps is, and how to install it. The home page's Get Started button leads tointro.md.guide/: getting started, then one page per framework binding (React, Vue, Nuxt, Svelte, Solid, stx, React Native) and an overview of them all.concepts/: how each part works, one topic a page: the map, layers, controls, styles and theming, the style spec, vector tiles, self-hosted tiles, 3D, terrain, services, offline, localization, territory capture.api/: the API reference, written by hand:Map, layers, expressions, geometry.examples/: small runnable maps.NN-name.tsis the example's source, and what runs.scripts/build-playground.tsbuilds each one into/playground/examples/NN-name.html, and the editor at/playground/examples/edit.html?example=NN-nameloads it to change and re-run.NN-name.mdis its page: what it shows, the running frame, links to full screen and the editor, and the code that matters.thumbs/NN-name.jpgis its picture in the gallery, taken byscripts/playground-thumbs.ts --examples.data/holds data too long to sit in an example's source, as modules the example imports (the indoor venue, the landmark model).index.mdis the gallery, generated byscripts/build-example-gallery.tsfrom the pages' headings and first sentences. It is committed, so it reads the same on GitHub; regenerate it rather than editing it.
demos/: a page for each playground demo inplayground/core-map/, generated byscripts/build-demo-pages.tson every build. Not committed (it is in.gitignore); change the demo, not its page.migration/: moving from Leaflet, Mapbox GL JS and MapLibre.credits.md: attribution for Leaflet and the Mapbox GL Style Spec.public/: static files served at the site root._data/: data the stacksjs pages read.
Plus the standard stacksjs pages: team.md, sponsors.md, showcase.md,
partners.md, stargazers.md, postcardware.md, plugins.md,
license.md.
Writing
- Link to other pages as files, relatively:
./concepts/map.md,../examples/02-camera.md. That works on GitHub, andscripts/fix-doc-links.tsturns each link into the page's URL on the built site. A link to another file indocs/, such as an example's.ts, goes to that file on GitHub. - Code samples import from
'ts-maps'and should run as written. - Basemaps in samples use OpenFreeMap, which is free and needs no key:
styles.light({ url: 'https://tiles.openfreemap.org/planet' }). - A new example is a pair,
NN-name.tsandNN-name.md, numbered after the last. The sidebar and the gallery pick it up; take its thumbnail withscripts/playground-thumbs.ts --examples.