///|
fn main {
let input =
#|+++
#|title = "MoonFolio example"
#|summary = "Runnable metadata folio example"
#|date = "2026-08-20"
#|draft = false
#|weight = 3
#|tags = ["moonbit", "metadata"]
#|permalink = "/examples/moonfolio-example"
#|+++
#|# Example
#|
#|A small Markdown document with TOML-style metadata.
let output = @moonfolio.parse_with_required(input, ["title", "tags"])
let contract = @moonfolio.validate_contract(output.document, [
{ key: "title", kind: @moonfolio.TextType, required: true },
{ key: "draft", kind: @moonfolio.BoolType, required: true },
{ key: "weight", kind: @moonfolio.IntType, required: true },
{ key: "tags", kind: @moonfolio.ListType, required: true },
])
let folio = @moonfolio.build_folio(output.document, "/examples")
let profile = @moonfolio.profile_with_allowed_tags(
@moonfolio.profile_with_permalink_prefix(
@moonfolio.profile_with_date_range(
@moonfolio.default_content_profile(),
2024,
2030,
),
"/examples",
),
["moonbit", "metadata"],
)
let profile_report = @moonfolio.evaluate_profile(output.document, profile)
let registry = @moonfolio.registry_from_documents(
[output.document],
"/examples",
)
let canonical = @moonfolio.canonicalize_document(output.document)
println(@moonfolio.summary(output))
println("contract=" + contract.ok.to_string())
println("profile-score=" + profile_report.score.to_string())
println(
"registry-health=" + @moonfolio.registry_health_score(registry).to_string(),
)
println("folio=" + folio.manifest_line)
println("canonical-fields=" + canonical.order.join(","))
println("body-size=" + output.document.body.length().to_string())
println(
"toml-roundtrip=" +
@moonfolio.to_toml(output.document).contains("weight = 3").to_string(),
)
}