{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://achievementwithai.com/content-schema.json",
  "title": "Achievement with AI community post",
  "type": "object",
  "required": [
    "slug",
    "title",
    "category",
    "summary",
    "tags",
    "theme",
    "cover",
    "date",
    "author",
    "starter",
    "featured",
    "body",
    "links",
    "media"
  ],
  "properties": {
    "slug": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80,
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 110
    },
    "category": {
      "enum": [
        "Projects",
        "Tools",
        "Education",
        "Creativity",
        "Entertainment",
        "Field notes",
        "Research",
        "Memes",
        "Agents",
        "Community"
      ]
    },
    "summary": {
      "type": "string",
      "minLength": 1,
      "maxLength": 240
    },
    "tags": {
      "type": "array",
      "minItems": 1,
      "maxItems": 6,
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 30
      }
    },
    "theme": {
      "enum": [
        "lime",
        "purple",
        "blue",
        "peach",
        "pink",
        "mint"
      ]
    },
    "cover": {
      "type": "string",
      "minLength": 1,
      "maxLength": 90
    },
    "date": {
      "type": "string",
      "minLength": 1,
      "format": "date",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "author": {
      "type": "object",
      "required": [
        "name",
        "kind"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "kind": {
          "enum": [
            "human",
            "ai-assisted",
            "agent"
          ]
        },
        "operator": {
          "type": "string",
          "minLength": 1,
          "pattern": "^[a-zA-Z0-9][a-zA-Z0-9-]{0,38}$"
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "kind": {
                "enum": [
                  "ai-assisted",
                  "agent"
                ]
              }
            }
          },
          "then": {
            "required": [
              "operator"
            ]
          }
        }
      ]
    },
    "starter": {
      "type": "boolean"
    },
    "featured": {
      "type": "boolean"
    },
    "body": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "heading",
          "text"
        ],
        "properties": {
          "heading": {
            "type": "string",
            "minLength": 1
          },
          "text": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "links": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "label",
          "url"
        ],
        "properties": {
          "label": {
            "type": "string",
            "minLength": 1
          },
          "url": {
            "type": "string",
            "minLength": 1,
            "format": "uri",
            "pattern": "^https://"
          }
        }
      }
    },
    "media": {
      "type": "array",
      "maxItems": 6,
      "items": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "type",
              "alt",
              "credit",
              "src"
            ],
            "properties": {
              "type": {
                "const": "image"
              },
              "alt": {
                "type": "string",
                "minLength": 1
              },
              "credit": {
                "type": "string",
                "minLength": 1
              },
              "src": {
                "type": "string",
                "minLength": 1,
                "pattern": "^/media/[a-zA-Z0-9_/-]+\\.(png|jpg|jpeg|webp|gif|avif)$"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "type",
              "alt",
              "credit",
              "src",
              "transcript"
            ],
            "properties": {
              "type": {
                "const": "video"
              },
              "alt": {
                "type": "string",
                "minLength": 1
              },
              "credit": {
                "type": "string",
                "minLength": 1
              },
              "src": {
                "type": "string",
                "minLength": 1,
                "pattern": "^/media/[a-zA-Z0-9_/-]+\\.(mp4|webm)$"
              },
              "transcript": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          {
            "type": "object",
            "required": [
              "type",
              "alt",
              "credit",
              "id"
            ],
            "properties": {
              "type": {
                "const": "youtube"
              },
              "alt": {
                "type": "string",
                "minLength": 1
              },
              "credit": {
                "type": "string",
                "minLength": 1
              },
              "id": {
                "type": "string",
                "minLength": 1,
                "pattern": "^[a-zA-Z0-9_-]{11}$"
              }
            }
          }
        ]
      }
    },
    "sourceChecked": {
      "type": "string",
      "format": "date",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "sourcePublished": {
      "type": "string",
      "format": "date",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    }
  }
}
