# Projects Metadata Schema
#
# Extends PostMetadata with project-specific fields: thumbnails,
# page route, and optional source HTML for embedded project pages.
#
# Usage — preferred (make_project factory):
#
#   let schema = import "content/metadata/projects_metadata.ncl" in
#   schema.make_project {
#     id         = "my-project",
#     title      = "My Project",
#     slug       = "my-project",
#     date       = "2024-01-01",
#     page_route = "/my-project",
#   }

let c    = import "contracts.ncl" in
let post = import "post_metadata.ncl" in
let d    = import "defaults.ncl" in

{
  ProjectMetadata = post.PostMetadata & {
    page_route
      | String
      | doc "Absolute URL path for the project's dedicated page. E.g. '/my-project'."
      | optional,

    thumbnail_dark
      | String
      | doc "Dark-mode card thumbnail. Root-relative path. Falls back to thumbnail when absent."
      | optional,

    source_html
      | String
      | doc "Absolute filesystem path to an external HTML file embedded in the project page."
      | optional,

    sort_order
      | Number
      | doc "Display order in the projects listing. Lower values appear first."
      | default = 100,
  },

  make_project
    | not_exported
    | doc "Create a validated project metadata record. Provide at minimum: title, slug, date."
    = fun overrides =>
        d & { category | default = "projects" } & overrides | ProjectMetadata,
}
