57 lines
1.7 KiB
Text
57 lines
1.7 KiB
Text
# Recipe Metadata Schema
|
|
#
|
|
# Extends PostMetadata with recipe/tutorial-specific fields.
|
|
# The additional fields map to `specialized = true` content types
|
|
# configured in content-kinds.ncl.
|
|
#
|
|
# Usage — preferred (make_recipe factory):
|
|
#
|
|
# let schema = import "site/nickel/content/metadata/recipe_metadata.ncl" in
|
|
# schema.make_recipe {
|
|
# title = "Async Error Handling in Rust",
|
|
# slug = "async-error-handling-in-rust",
|
|
# date = "2024-01-12",
|
|
# category = "async-programming",
|
|
# difficulty = "intermediate",
|
|
# duration = "30 min",
|
|
# }
|
|
|
|
let c = import "contracts.ncl" in
|
|
let post = import "post_metadata.ncl" in
|
|
let d = import "defaults.ncl" in
|
|
|
|
{
|
|
RecipeMetadata = post.PostMetadata & {
|
|
# --- Recipe-specific ---
|
|
|
|
difficulty
|
|
| String
|
|
| c.DifficultyLevel
|
|
| doc "Skill level required: 'beginner', 'intermediate', or 'advanced'"
|
|
| optional,
|
|
|
|
duration
|
|
| String
|
|
| c.ReadTimeContract
|
|
| doc "Total estimated time to follow the recipe. E.g. '30 min', '2 hours'."
|
|
| optional,
|
|
|
|
prerequisites
|
|
| Array String
|
|
| doc "Concepts, tools, or recipes the reader should know before starting"
|
|
| default = [],
|
|
|
|
tools
|
|
| Array String
|
|
| doc "Software, crates, or commands used in this recipe"
|
|
| default = [],
|
|
},
|
|
|
|
# Factory function — Layer 1 (defaults) & Layer 2 (overrides) | contract.
|
|
# Not exported to JSON; accessible only via Nickel import.
|
|
make_recipe
|
|
| not_exported
|
|
| doc "Create a validated recipe metadata record. Provide at minimum: title, slug, date, category."
|
|
= fun overrides =>
|
|
d & overrides | RecipeMetadata,
|
|
}
|