Skip to content

CONSUME-AS-DATA-02: Read one section's prose two ways

The same SectionView is reachable by camelCase key and by the exact .section(name) accessor.

Builds on: CONSUME-AS-DATA-01: Open the read() door for typed frontmatter

A TypeScript program against the library API; inline comments show the resulting values and behavior.

const doc = c.read(src, { path: "notes/note.md" });
// Dual-key: dotted camelCase field...
const a = doc.body.summary.text();
// ...and the exact-heading accessor resolve the same SectionView.
const b = doc.body.section("Summary").text();
console.log(a === b); // true — one view, two keys
  • Doc.body dual-key access (doc.body.summary and doc.body.section("Summary"))
  • SectionView.text("prose")