ts-maps

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:

  1. scripts/build-example-gallery.ts writes examples/index.md.
  2. scripts/build-demo-pages.ts writes demos/.
  3. BunPress builds the site.
  4. scripts/fix-doc-links.ts rewrites 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 to intro.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.ts is the example's source, and what runs. scripts/build-playground.ts builds each one into /playground/examples/NN-name.html, and the editor at /playground/examples/edit.html?example=NN-name loads it to change and re-run.
    • NN-name.md is its page: what it shows, the running frame, links to full screen and the editor, and the code that matters.
    • thumbs/NN-name.jpg is its picture in the gallery, taken by scripts/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.md is the gallery, generated by scripts/build-example-gallery.ts from 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 in playground/core-map/, generated by scripts/build-demo-pages.ts on 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, and scripts/fix-doc-links.ts turns each link into the page's URL on the built site. A link to another file in docs/, 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.ts and NN-name.md, numbered after the last. The sidebar and the gallery pick it up; take its thumbnail with scripts/playground-thumbs.ts --examples.