{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Quartz Plugins Configuration Schema",
  "description": "Schema for validating quartz.plugins.json configuration files",
  "type": "object",
  "required": ["configuration", "plugins"],
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string",
      "description": "JSON Schema reference"
    },
    "configuration": {
      "type": "object",
      "required": ["pageTitle", "enableSPA", "locale", "theme"],
      "additionalProperties": false,
      "properties": {
        "pageTitle": {
          "type": "string",
          "description": "The title of the website"
        },
        "pageTitleSuffix": {
          "type": "string",
          "description": "Suffix appended to page titles"
        },
        "enableSPA": {
          "type": "boolean",
          "description": "Enable single-page application mode"
        },
        "enablePopovers": {
          "type": "boolean",
          "description": "Enable hover popovers for links"
        },
        "locale": {
          "type": "string",
          "description": "Locale code for the site"
        },
        "baseUrl": {
          "type": "string",
          "description": "Base URL for the site"
        },
        "theme": {
          "type": "object",
          "required": ["fontOrigin", "cdnCaching", "typography", "colors"],
          "additionalProperties": false,
          "properties": {
            "fontOrigin": {
              "type": "string",
              "enum": ["googleFonts", "local"],
              "description": "Source of fonts"
            },
            "cdnCaching": {
              "type": "boolean",
              "description": "Enable CDN caching"
            },
            "typography": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "header": {
                  "type": "string",
                  "description": "Font family for headers"
                },
                "body": {
                  "type": "string",
                  "description": "Font family for body text"
                },
                "code": {
                  "type": "string",
                  "description": "Font family for code"
                }
              }
            },
            "colors": {
              "type": "object",
              "required": ["lightMode", "darkMode"],
              "additionalProperties": false,
              "properties": {
                "lightMode": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "light": {
                      "type": "string",
                      "description": "Light color"
                    },
                    "lightgray": {
                      "type": "string",
                      "description": "Light gray color"
                    },
                    "gray": {
                      "type": "string",
                      "description": "Gray color"
                    },
                    "darkgray": {
                      "type": "string",
                      "description": "Dark gray color"
                    },
                    "dark": {
                      "type": "string",
                      "description": "Dark color"
                    },
                    "secondary": {
                      "type": "string",
                      "description": "Secondary color"
                    },
                    "tertiary": {
                      "type": "string",
                      "description": "Tertiary color"
                    },
                    "highlight": {
                      "type": "string",
                      "description": "Highlight color"
                    },
                    "textHighlight": {
                      "type": "string",
                      "description": "Text highlight color"
                    }
                  }
                },
                "darkMode": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "light": {
                      "type": "string",
                      "description": "Light color"
                    },
                    "lightgray": {
                      "type": "string",
                      "description": "Light gray color"
                    },
                    "gray": {
                      "type": "string",
                      "description": "Gray color"
                    },
                    "darkgray": {
                      "type": "string",
                      "description": "Dark gray color"
                    },
                    "dark": {
                      "type": "string",
                      "description": "Dark color"
                    },
                    "secondary": {
                      "type": "string",
                      "description": "Secondary color"
                    },
                    "tertiary": {
                      "type": "string",
                      "description": "Tertiary color"
                    },
                    "highlight": {
                      "type": "string",
                      "description": "Highlight color"
                    },
                    "textHighlight": {
                      "type": "string",
                      "description": "Text highlight color"
                    }
                  }
                }
              }
            }
          }
        },
        "analytics": {
          "type": "object",
          "description": "Analytics configuration"
        },
        "ignorePatterns": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Patterns to ignore during processing"
        }
      }
    },
    "plugins": {
      "type": "array",
      "description": "Array of plugin configurations",
      "items": {
        "type": "object",
        "required": ["source", "enabled"],
        "additionalProperties": false,
        "properties": {
          "source": {
            "oneOf": [
              {
                "type": "string",
                "description": "Plugin source path or identifier. Supports github:user/repo, git+https://, and https:// URLs. Append #ref to pin to a specific branch or tag (e.g., github:user/repo#my-branch). Local file paths (e.g., ./my-plugin, ../sibling-plugin, /absolute/path) are also supported for local development or airgapped environments."
              },
              {
                "type": "object",
                "required": ["repo"],
                "additionalProperties": false,
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Override name for the plugin directory. If omitted, the name is derived from the repository URL."
                  },
                  "repo": {
                    "type": "string",
                    "description": "Git repository URL (e.g., https://github.com/user/repo.git). Supports the same URL formats as the string source."
                  },
                  "subdir": {
                    "type": "string",
                    "description": "Subdirectory within the repository containing the plugin. Used when the plugin is not at the repository root."
                  },
                  "ref": {
                    "type": "string",
                    "description": "Git ref (branch or tag) to pin to. If omitted, the default branch is used."
                  }
                },
                "description": "Object source with explicit repo URL and optional subdirectory, ref, and name overrides for monorepo-style plugins."
              }
            ],
            "description": "Plugin source: either a string path/identifier or an object with repo/subdir configuration."
          },
          "enabled": {
            "type": "boolean",
            "description": "Whether the plugin is enabled"
          },
          "order": {
            "type": "number",
            "minimum": 0,
            "description": "Plugin execution order"
          },
          "options": {
            "type": "object",
            "additionalProperties": true,
            "description": "Plugin-specific options"
          },
          "layout": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "position": {
                "type": "string",
                "enum": ["left", "right", "beforeBody", "afterBody", "body"],
                "description": "Layout position"
              },
              "priority": {
                "type": "number",
                "description": "Layout priority"
              },
              "display": {
                "type": "string",
                "enum": ["all", "mobile-only", "desktop-only"],
                "description": "Display mode"
              },
              "condition": {
                "type": "string",
                "description": "Conditional display logic"
              },
              "group": {
                "type": "string",
                "description": "Layout group name"
              },
              "groupOptions": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "grow": {
                    "type": "boolean",
                    "description": "Flex grow"
                  },
                  "shrink": {
                    "type": "boolean",
                    "description": "Flex shrink"
                  },
                  "basis": {
                    "type": "string",
                    "description": "Flex basis"
                  },
                  "order": {
                    "type": "number",
                    "description": "Flex order"
                  },
                  "align": {
                    "type": "string",
                    "description": "Alignment"
                  },
                  "justify": {
                    "type": "string",
                    "description": "Justification"
                  }
                }
              }
            }
          }
        }
      }
    },
    "layout": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "groups": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "direction": {
                "type": "string",
                "description": "Flex direction"
              },
              "wrap": {
                "type": "boolean",
                "description": "Flex wrap"
              },
              "gap": {
                "type": "string",
                "description": "Gap between items"
              }
            }
          },
          "description": "Layout groups configuration"
        },
        "byPageType": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "exclude": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Excluded plugins for this page type"
              },
              "positions": {
                "type": "object",
                "description": "Position overrides for this page type"
              }
            }
          },
          "description": "Layout configuration by page type"
        }
      }
    }
  }
}
