{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://zeropress.dev/schemas/zeropress-build-pages.config.v0.1.schema.json",
  "title": "ZeroPress Build Pages Config v0.1",
  "description": "Optional source-directory configuration for @zeropress/build-pages workflows.",
  "markdownDescription": "Optional source-directory configuration for `@zeropress/build-pages` workflows.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string",
      "description": "Optional JSON Schema URI or path used by editors and tooling.",
      "markdownDescription": "Optional JSON Schema URI or path used by editors and tooling."
    },
    "version": {
      "type": "string",
      "const": "0.1",
      "description": "ZeroPress Build Pages config format version.",
      "markdownDescription": "ZeroPress Build Pages config format version."
    },
    "site": {
      "$ref": "#/$defs/site"
    },
    "front_page": {
      "$ref": "#/$defs/frontPage"
    },
    "custom_html": {
      "$ref": "#/$defs/customHtml"
    },
    "menus": {
      "$ref": "#/$defs/menus"
    }
  },
  "$defs": {
    "site": {
      "type": "object",
      "additionalProperties": false,
      "description": "User-facing site metadata used by Build Pages.",
      "markdownDescription": "User-facing site metadata used by Build Pages.",
      "properties": {
        "title": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "description": "Canonical site URL. Use an empty string or omit this field for local builds without canonical output.",
          "markdownDescription": "Canonical site URL. Use an empty string or omit this field for local builds without canonical output."
        },
        "footer": {
          "$ref": "#/$defs/siteFooter"
        }
      }
    },
    "siteFooter": {
      "type": "object",
      "additionalProperties": false,
      "description": "Optional footer display data copied into generated preview-data.",
      "markdownDescription": "Optional footer display data copied into generated preview-data.",
      "properties": {
        "copyright_text": {
          "type": "string",
          "minLength": 1,
          "description": "Footer copyright or legal text. ZeroPress does not add a copyright symbol automatically.",
          "markdownDescription": "Footer copyright or legal text. ZeroPress does not add a copyright symbol automatically."
        },
        "attribution": {
          "$ref": "#/$defs/siteFooterAttribution"
        }
      }
    },
    "siteFooterAttribution": {
      "type": "object",
      "additionalProperties": false,
      "description": "Optional ZeroPress attribution display policy for themes.",
      "markdownDescription": "Optional ZeroPress attribution display policy for themes.",
      "properties": {
        "enabled": {
          "type": "boolean",
          "description": "When false, bundled themes hide the Published with ZeroPress attribution. Missing or true means attribution may be shown.",
          "markdownDescription": "When `false`, bundled themes hide the Published with ZeroPress attribution. Missing or `true` means attribution may be shown."
        }
      }
    },
    "frontPage": {
      "type": "object",
      "additionalProperties": false,
      "required": ["type"],
      "description": "Source file or theme template used for the site root.",
      "markdownDescription": "Source file or theme template used for the site root.",
      "properties": {
        "type": {
          "type": "string",
          "enum": ["theme_index", "markdown", "html"],
          "default": "theme_index",
          "description": "Front page source mode. theme_index uses theme/index.html. markdown and html read a source file.",
          "markdownDescription": "Front page source mode. `theme_index` uses `theme/index.html`. `markdown` and `html` read a source file."
        },
        "file": {
          "$ref": "#/$defs/sourceFilePath",
          "description": "Optional source-root relative file path. Defaults to index.md for markdown and .zeropress/index.html for html.",
          "markdownDescription": "Optional source-root relative file path. Defaults to `index.md` for `markdown` and `.zeropress/index.html` for `html`."
        },
        "layout": {
          "type": "boolean",
          "default": true,
          "description": "Only applies to html front pages. true renders the file as page body content through the ZeroPress layout; false treats it as a full standalone HTML document.",
          "markdownDescription": "Only applies to `html` front pages. `true` renders the file as page body content through the ZeroPress layout; `false` treats it as a full standalone HTML document."
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "type": { "const": "theme_index" }
            },
            "required": ["type"]
          },
          "then": {
            "not": {
              "anyOf": [
                { "required": ["file"] },
                { "required": ["layout"] }
              ]
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": { "const": "markdown" }
            },
            "required": ["type"]
          },
          "then": {
            "not": {
              "required": ["layout"]
            },
            "properties": {
              "file": {
                "type": "string",
                "pattern": "\\.md$"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": { "const": "html" }
            },
            "required": ["type"]
          },
          "then": {
            "properties": {
              "file": {
                "type": "string",
                "pattern": "^\\.zeropress/.+\\.html$"
              }
            }
          }
        }
      ]
    },
    "sourceFilePath": {
      "type": "string",
      "minLength": 1,
      "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*[?#]).+$",
      "description": "Source-root relative path. Leading slash, parent-directory traversal, query strings, and hash fragments are not allowed.",
      "markdownDescription": "Source-root relative path. Leading slash, parent-directory traversal, query strings, and hash fragments are not allowed."
    },
    "customHtml": {
      "type": "object",
      "additionalProperties": false,
      "minProperties": 1,
      "description": "Trusted HTML snippets copied into preview-data custom_html slots.",
      "markdownDescription": "Trusted HTML snippets copied into preview-data `custom_html` slots.",
      "properties": {
        "head_end": {
          "$ref": "#/$defs/customHtmlSlot",
          "description": "HTML file injected before </head> by ZeroPress build.",
          "markdownDescription": "HTML file injected before `</head>` by ZeroPress build."
        },
        "body_end": {
          "$ref": "#/$defs/customHtmlSlot",
          "description": "HTML file injected before </body> by ZeroPress build.",
          "markdownDescription": "HTML file injected before `</body>` by ZeroPress build."
        }
      }
    },
    "customHtmlSlot": {
      "type": "object",
      "additionalProperties": false,
      "required": ["file"],
      "properties": {
        "file": {
          "allOf": [
            { "$ref": "#/$defs/sourceFilePath" },
            {
              "type": "string",
              "pattern": "^\\.zeropress/.+\\.html$"
            }
          ],
          "description": "Prebuild-only HTML file inside .zeropress/.",
          "markdownDescription": "Prebuild-only HTML file inside `.zeropress/`."
        }
      }
    },
    "menus": {
      "type": "object",
      "description": "Menu definitions copied into generated preview-data.",
      "markdownDescription": "Menu definitions copied into generated preview-data.",
      "propertyNames": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9_-]{0,63}$"
      },
      "additionalProperties": {
        "$ref": "#/$defs/menu"
      }
    },
    "menu": {
      "type": "object",
      "additionalProperties": false,
      "required": ["items"],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/menuItem"
          }
        }
      }
    },
    "menuItem": {
      "type": "object",
      "additionalProperties": false,
      "required": ["title", "url"],
      "properties": {
        "title": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "enum": ["custom", "page", "post", "category"],
          "default": "custom"
        },
        "target": {
          "type": "string",
          "enum": ["_self", "_blank"],
          "default": "_self"
        },
        "children": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/menuItem"
          },
          "default": []
        }
      }
    }
  },
  "examples": [
    {
      "$schema": "../schemas/zeropress-build-pages.config.v0.1.schema.json",
      "version": "0.1",
      "site": {
        "title": "ZeroPress Public Docs",
        "description": "Public documentation.",
        "url": "https://zeropress.dev"
      },
      "front_page": {
        "type": "markdown"
      },
      "custom_html": {
        "head_end": {
          "file": ".zeropress/head-end.html"
        },
        "body_end": {
          "file": ".zeropress/body-end.html"
        }
      },
      "menus": {
        "primary": {
          "name": "Primary Menu",
          "items": [
            { "title": "Home", "url": "/" },
            { "title": "Docs", "url": "/docs/" }
          ]
        }
      }
    }
  ]
}
