{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://zeropress.dev/schemas/preview-data.v0.3.schema.json",
  "title": "ZeroPress Theme Preview Data v0.3",
  "type": "object",
  "additionalProperties": false,
  "required": ["version", "generator", "generated_at", "site", "content", "routes"],
  "properties": {
    "version": {
      "const": "0.3"
    },
    "generator": {
      "type": "string",
      "minLength": 1
    },
    "generated_at": {
      "type": "string",
      "format": "date-time"
    },
    "site": {
      "$ref": "#/$defs/site"
    },
    "content": {
      "$ref": "#/$defs/content"
    },
    "routes": {
      "$ref": "#/$defs/routes"
    }
  },
  "$defs": {
    "site": {
      "type": "object",
      "required": ["title", "description", "url", "language"],
      "properties": {
        "title": { "type": "string", "minLength": 1 },
        "description": { "type": "string" },
        "url": {
          "type": "string",
          "anyOf": [
            { "const": "" },
            { "format": "uri" }
          ]
        },
        "language": { "type": "string", "minLength": 2 },
        "logo": { "type": "string", "format": "uri" },
        "social": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        }
      },
      "additionalProperties": true
    },
    "previewPost": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "public_id",
        "title",
        "slug",
        "html",
        "excerpt",
        "published_at",
        "updated_at",
        "published_at_iso",
        "updated_at_iso",
        "reading_time",
        "author_name",
        "categories_html",
        "tags_html",
        "comments_html",
        "status"
      ],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "public_id": { "type": "integer", "minimum": 1 },
        "title": { "type": "string", "minLength": 1 },
        "slug": { "type": "string", "minLength": 1 },
        "html": { "type": "string" },
        "excerpt": { "type": "string" },
        "published_at": { "type": "string" },
        "updated_at": { "type": "string" },
        "published_at_iso": { "type": "string", "format": "date-time" },
        "updated_at_iso": { "type": "string", "format": "date-time" },
        "reading_time": { "type": "string", "minLength": 1 },
        "author_name": { "type": "string", "minLength": 1 },
        "author_avatar": { "type": "string", "format": "uri" },
        "featured_image": { "type": "string", "format": "uri" },
        "categories_html": { "type": "string" },
        "tags_html": { "type": "string" },
        "comments_html": { "type": "string" },
        "status": {
          "type": "string",
          "enum": ["published", "draft"]
        }
      }
    },
    "previewPage": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "title", "slug", "html", "status"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "title": { "type": "string", "minLength": 1 },
        "slug": { "type": "string", "minLength": 1 },
        "html": { "type": "string" },
        "status": {
          "type": "string",
          "enum": ["published", "draft"]
        }
      }
    },
    "previewCategory": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "name", "slug", "postCount"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "name": { "type": "string", "minLength": 1 },
        "slug": { "type": "string", "minLength": 1 },
        "description": { "type": "string" },
        "postCount": { "type": "integer", "minimum": 0 }
      }
    },
    "previewTag": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "name", "slug", "postCount"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "name": { "type": "string", "minLength": 1 },
        "slug": { "type": "string", "minLength": 1 },
        "postCount": { "type": "integer", "minimum": 0 }
      }
    },
    "content": {
      "type": "object",
      "additionalProperties": false,
      "required": ["posts", "pages", "categories", "tags"],
      "properties": {
        "posts": {
          "type": "array",
          "items": { "$ref": "#/$defs/previewPost" }
        },
        "pages": {
          "type": "array",
          "items": { "$ref": "#/$defs/previewPage" }
        },
        "categories": {
          "type": "array",
          "items": { "$ref": "#/$defs/previewCategory" }
        },
        "tags": {
          "type": "array",
          "items": { "$ref": "#/$defs/previewTag" }
        }
      }
    },
    "paginatedRouteBase": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "page", "totalPages", "posts", "pagination"],
      "properties": {
        "path": { "type": "string", "minLength": 1 },
        "page": { "type": "integer", "minimum": 1 },
        "totalPages": { "type": "integer", "minimum": 1 },
        "posts": { "type": "string" },
        "pagination": { "type": "string" },
        "categories": { "type": "string" },
        "tags": { "type": "string" },
        "slug": { "type": "string", "minLength": 1 }
      }
    },
    "indexRoute": {
      "allOf": [
        { "$ref": "#/$defs/paginatedRouteBase" },
        { "required": ["path", "page", "totalPages", "posts", "pagination", "categories", "tags"] }
      ]
    },
    "archiveRoute": {
      "allOf": [
        { "$ref": "#/$defs/paginatedRouteBase" },
        { "required": ["path", "page", "totalPages", "posts", "pagination"] }
      ]
    },
    "categoryRoute": {
      "allOf": [
        { "$ref": "#/$defs/paginatedRouteBase" },
        { "required": ["path", "page", "totalPages", "slug", "posts", "pagination"] }
      ]
    },
    "tagRoute": {
      "allOf": [
        { "$ref": "#/$defs/paginatedRouteBase" },
        { "required": ["path", "page", "totalPages", "slug", "posts", "pagination"] }
      ]
    },
    "routes": {
      "type": "object",
      "additionalProperties": false,
      "required": ["index", "archive", "categories", "tags"],
      "properties": {
        "index": {
          "type": "array",
          "items": { "$ref": "#/$defs/indexRoute" }
        },
        "archive": {
          "type": "array",
          "items": { "$ref": "#/$defs/archiveRoute" }
        },
        "categories": {
          "type": "array",
          "items": { "$ref": "#/$defs/categoryRoute" }
        },
        "tags": {
          "type": "array",
          "items": { "$ref": "#/$defs/tagRoute" }
        }
      }
    }
  }
}
