WORK-213
Setting up your dashboard 0 entities found · 6/29 branches scanned
ID:WORK-213Status:done

Frontmatter schema extension (tint, tint-mode, tint-lock)

Add the three cascade fields — tint, tint-mode, tint-lock — to the validated frontmatter shape for both _layout.md files and page frontmatter. Validates values, rejects invalid types/values with clear errors, distinguishes YAML null from missing per the cascade semantics.

Priority:highComplexity:smallMilestone:v0.14.0Source:SPEC-052

Criteria completion

Criteria completion: 7 of 7 (100%) checked; history from May 18 to May 180%25%50%75%100%May 18May 18
Branches 2
History 4
  1. 7478366
    • ☑ `tint?: string | null` accepted in layout and page frontmatter; named tints validated against the configured tint registry where possible (warn rather than fail if an unknown tint is referenced, since tints may be added/removed at runtime)
    • ☑ `tint-mode?: 'auto' | 'light' | 'dark'` accepted; invalid values produce a clear error (`"tint-mode must be one of: auto, light, dark"`)
    • ☑ `tint-lock?: boolean` accepted; non-boolean values rejected with a clear error
    • ☑ YAML `null` (`tint: ~` or `tint: null` in YAML) is preserved as JS `null` through parsing — distinguishable from missing
    • ☑ Missing fields don't appear in the parsed frontmatter object (or are explicitly `undefined`) — distinguishable from `null`
    • ☑ Validation errors include the source file path and line number when possible
    • ☑ Unit tests cover: each valid value, each invalid value type, null vs missing distinction, validation failure messages
    by bjornolofandersson
  2. e515b1c
    Content editedby Claude
    v0.14.0 Chunk 9: SPEC-052 cascade machinery (WORK-212, 213, 214-helpers)
  3. 3b92415
    Created (ready)by bjornolofandersson
  4. 8df92a3
    Content editedby Claude
    plan: add SPEC-052 tint cascade work items (WORK-211 to 216)

Acceptance Criteria

  • tint?: string | null accepted in layout and page frontmatter; named tints validated against the configured tint registry where possible (warn rather than fail if an unknown tint is referenced, since tints may be added/removed at runtime)
  • tint-mode?: 'auto' | 'light' | 'dark' accepted; invalid values produce a clear error ("tint-mode must be one of: auto, light, dark")
  • tint-lock?: boolean accepted; non-boolean values rejected with a clear error
  • YAML null (tint: ~ or tint: null in YAML) is preserved as JS null through parsing — distinguishable from missing
  • Missing fields don't appear in the parsed frontmatter object (or are explicitly undefined) — distinguishable from null
  • Validation errors include the source file path and line number when possible
  • Unit tests cover: each valid value, each invalid value type, null vs missing distinction, validation failure messages

Approach

Schema extension in whichever module owns frontmatter parsing — likely packages/content/ or packages/types/. Most projects use a runtime schema validator; check what refrakt already uses.

The null vs missing distinction is the most error-prone part. Most YAML parsers handle it correctly by default, but the JS layer often coerces both to undefined. Write a specific test that parses both tint: (empty) and tint: ~ and confirms the parsed object distinguishes them.

The named-tint validation is advisory, not strict — a tint might be added in a plugin loaded after the page is parsed, or removed at runtime via config changes. Warn on unknown names; don't fail builds. The cascade resolution in WORK-212 will just pass the unknown name through; the engine in WORK-214 will set data-tint="unknown-name" which simply won't match any defined tint.

Dependencies

None (or minimal — independent of SPEC-048 since frontmatter parsing already exists). Can start in parallel with the foundation work.

References

  • SPEC-052 — "Frontmatter Authoring Surface" section
  • The frontmatter validation surface — locate during implementation; the field-naming convention is the same as the existing rune attributes