Skip to main content

Module content

Module content 

Source
Expand description

Typed content collections with frontmatter schema validation.

§Typed content collections with frontmatter schema validation

Defines content schemas in content.schema.toml and validates every Markdown file’s frontmatter against the matching schema before compilation begins.

§Schema file format

[[schemas]]
name = "post"

[[schemas.fields]]
name = "title"
type = "string"
required = true

[[schemas.fields]]
name = "date"
type = "date"
required = true

[[schemas.fields]]
name = "draft"
type = "bool"
required = false
default = "false"

§Supported field types

string, date, bool, integer, float, list, enum(value1,value2,...).

Structs§

ContentSchema
A named collection of field definitions.
ContentValidationPlugin
Plugin that validates content frontmatter against schemas defined in content.schema.toml during the before_compile hook.
FieldDef
Definition of a single frontmatter field.
ValidationError
A single validation error with file context.

Enums§

FieldType
The type of a frontmatter field.

Functions§

load_schemas
Loads all content schemas from a content.schema.toml file.
parse_schemas
Parses the TOML text of a schema file into ContentSchema values.
validate_content_dir
Validates every .md file in content_dir against the loaded schemas.
validate_frontmatter
Validates a frontmatter map against a ContentSchema.
validate_only
Runs content schema validation without building the site.
validate_with_schema
Validates every .md file under content_dir against the schema at schema_path.