Documentation

<Document>

Markup the app did not author, shown as it was authored.

<Document src="/guide/intro.html" onNavigate={(url) => $navigate(url)} class="w-full h-full" />

Why this exists

A book already rendered as a documentation site is a document with structure the app should not rewrite. Porting it into screens means re-implementing its stylesheet and typography and then keeping two renderers in agreement. <Document> shows the HTML as it is, and its stylesheet, fonts and images resolve beside it in static/.

Source

src is a rooted path into static/, checked at build time. A missing src is a build error. A document in a folder the user chose comes from $folder:

<Document src={library.page("book/03.html")} class="w-full h-full" />

page(path) returns an address the document can resolve its siblings against, so relative links inside the page work from the granted folder too.

Links

A document never navigates itself. onNavigate receives the address of a link the reader taps, and what to do with it is the app's decision: route it, open it, or ignore it. With no handler a tapped link does nothing.

<Document
  src="/guide/intro.html"
  onNavigate={(url) => $navigate(url)}
  class="w-full h-full"
/>
Local only. A remote document is a browsing session, so a URL in src is a build error. Use $open to send the reader to a web page (see $open and $share).

A viewport, not a browser

There is no script, no bridge, no cookies, no history and no zoom controls. The name is not <WebView> for that reason: a name that promises a browser and delivers a viewport would be wrong.

See Also

  • $folder — documents the user downloaded or chose
  • $open and $share — for a link that should leave the app
  • Images — the same rooted-path rule