Duolith docs

field-notes

A small notes app with an app manifest in duolith.yaml (name, id, version and build, icon, launch screen, orientation, link domain and URL scheme), a /notes/[id] screen that links open, an href to another site and an environment value, for the native shells (docs/guide/native-apps.md).

Run it

cargo run -p duolith-cli -- dev examples/field-notes     # live, reloads on save
cargo run -p duolith-cli -- build examples/field-notes   # static output in examples/field-notes/dist

The folder on the web: examples/field-notes.

Features it shows

FeatureWhereScreenshot
The app manifest in duolith.yaml (name, id, version and build, icon at every density, launch screen, orientation, oldest systems, link domains and URL scheme), checked with E0470 to E0477 and written into the Android and iOS projects (decision 0140)field-notes duolith.yaml; dist-native/native/ after a buildcrates/cli/src/manifest/tests.rs; the CI Android job, which builds it into the shell's APK
An href to another site opened by the system (openUrl on the DuolithShell module); DUOLITH_PUBLIC_* values as environment() on a phonefield-notes pages/index.duopackages/engine/test/native-shell-in-browser.test.ts

Source

duolith.yaml
# The app manifest (decision 0140): what the native build writes into the
# Android and iOS projects. `duolith build --target native` checks it, and
# `duolith ship android|ios` builds a store release from it.
app:
  name: Field Notes
  display-name: Notes
  id: dev.duolith.fieldnotes
  version: 1.0.0
  build: 1
  icon: assets/icon.png
  splash:
    image: assets/splash.png
    background: { light: "#f6f5f2", dark: "#111214" }
  orientation: portrait
  ios:
    minimum: "15.0"
  android:
    minimum: 26
  links:
    domains: [notes.example.com]
    scheme: fieldnotes
locales/en.json
{
  "notes": {
    "title": "Field Notes",
    "opened-from": "Opened from {source}"
  }
}
pages/index.duo
---
import { environment } from "@duolith/client";

// DUOLITH_PUBLIC_API_URL, when the build had it, reaches the app as apiUrl.
let settings = environment({ apiUrl: "http://localhost:4480" });
const notes = [
  { id: 1, title: "Birds at the lake" },
  { id: 2, title: "Moss on the north wall" },
  { id: 3, title: "Night sounds" },
];
---

<screen title="Field Notes" class="p-4 gap-3">
  <text class="text-title text-ink">Field Notes</text>
  <text class="text-caption text-muted">
    A link to https://notes.example.com/notes/2 or fieldnotes://notes/2 opens the app on that note.
  </text>
  <list each={notes} as="note" key={note.id} class="gap-2">
    <view href={`/notes/${note.id}`} class="p-3 rounded-md bg-surface pressed:opacity-75">
      <text class="text-body text-ink">{note.title}</text>
    </view>
  </list>
  <text href="https://example.com/field-guide" class="text-body text-primary">
    Open the field guide in the browser
  </text>
  <text class="text-caption text-muted">Notes sync with {settings.apiUrl}</text>
</screen>
pages/notes/[id].duo
---
import { route } from "@duolith/client";

let { id } = route();
---

<screen title="Note" class="p-4 gap-3">
  <text class="text-title text-ink">Note {id}</text>
  <show when={route().query["from"]}>
    <text class="text-body text-ink">Opened from {route().query["from"]}</text>
  </show>
  <text href="/" class="text-body text-primary">All notes</text>
</screen>