Skip to main content

Module paths

Module paths 

Source
Expand description

The two path forms (spec/surface §1 “Paths”, 2.0). The store keeps a document’s path in git’s repo-relative form (projects/oqx.md: docs.path, the adapters, every store/sync spec), while every reference an author writes — a Markdown link, a wikilink, a frontmatter relation — is root-absolute (/projects/oqx.md). The surface speaks the reference form: every path a query, a tool or a CLI verb RETURNS is /-rooted, and every path they ACCEPT tolerates both forms. These two functions are the whole conversion; the store never sees a rooted path and the surface never hands out a bare one. Port of packages/core/src/core/paths.ts.

Functions§

reference_json
reference_path over a JSON string value; anything else passes through.
reference_keyed
Re-key a { <path>: … } object (the dry-run diffs) by the reference form, positions kept.
reference_path
The reference (surface) form of a storage path: exactly one leading /. "" (the repo root, docs_tree’s prefix) becomes /.
root_field
Root the string under key of a JSON object in place (a non-string or absent value is left alone).
storage_path
The storage form of a path a caller handed in: every leading / stripped (a missing slash is fine, an extra one is forgiven).