Skip to main content

Module schema_fields

Module schema_fields 

Source
Expand description

Builtin frontmatter field definitions.

This module is the single source of truth for all frontmatter fields that moss recognizes. The schema returned by [schema::builtin_schema()] is generated from the BUILTIN_FIELDS table, not from a hand-maintained JSON file. This eliminates drift between the build pipeline’s FrontMatter struct and the editor/validation schema.

§Adding a new field

  1. Add the field to FrontMatter in crates/moss-core/src/frontmatter_typed.rs.
  2. Add a corresponding entry to BUILTIN_FIELDS in this file.

Both files live in the same crate — add new fields to both in the same commit. Co-location and PR review are the enforcement mechanism.

§skip_schema fields

Fields with skip_schema: true exist in the FrontMatter struct (the build pipeline uses them) but are not exposed in the editor form or validation schema. These are typically site-level config fields read only from the homepage, auto-generated fields, or fields that will migrate to plugin- contributed schemas.

§Scope groups (displayed order)

Fields are assigned to one of five scope groups, ordered broad to narrow:

  1. “This Page” — per-page content and display properties
  2. “Child Pages” — controls how children are listed
  3. “Child Styles” — visual/layout controls for child listings
  4. “Whole Site” — properties read from the homepage to affect the whole site
  5. “Other” — unknown user-authored fields (catch-all, TS side only)

§Scoring

Each field carries a score value that drives BOTH the chip-bar visible order AND the add-property search-list order (lower score = first / more prominent). Score is computed as: score = 100 - (Frequency * 6 + Importance * 4) where Frequency and Importance are each 0..=5 (higher = more common/important). This means the maximum possible score is 100 (Frequency=0, Importance=0) and the minimum is 100 - (56 + 54) = 0 (Frequency=5, Importance=5). A lower score sorts earlier (more prominent position).

Structs§

BuiltinField
A builtin frontmatter field definition.

Constants§

BUILTIN_FIELDS
All builtin frontmatter fields recognized by moss.

Functions§

asset_field_names
Frontmatter fields whose value is a path to a file in the project.