{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://c0ntroller.de/content/list.schema.json",
    "title": "Content List",
    "description": "A list of projects and diaries for my homepage.",
    "type": "array",
    "items": {
        "anyOf": [
            { "$ref": "#/$defs/project" },
            { "$ref": "#/$defs/diary" }
        ]
    },
    "$defs": {
        "content": {
            "type": "object",
            "properties": {
                "type": {
                    "type": "string",
                    "enum": ["project", "diary"]
                },
                "name": {
                    "type": "string",
                    "pattern": "^[a-z0-9-_]+$"
                },
                "short_desc": {
                    "type": "string",
                    "maxLength": 100
                },
                "desc": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "more": {
                    "type": "string",
                    "format": "uri"
                },
                "repo": {
                    "type": "string",
                    "format": "uri"
                },
                "title": {
                    "type": "string",
                    "maxLength": 50
                }
            },
            "required": ["type", "name", "short_desc", "desc", "title"]
        },
        "project": {
            "type": "object",
            "allOf": [
                { "$ref": "#/$defs/content" }
            ],
            "properties": {
                "type": {
                    "const": "project"
                }
            }
        },
        "diary": {
            "type": "object",
            "allOf": [
                { "$ref": "#/$defs/content" }
            ],
            "properties": {
                "type": {
                    "const": "diary"
                },
                "entries": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "title": {
                                "type": "string"
                            },
                            "filename": {
                                "type": "string"
                            }
                        },
                        "required": ["title", "filename"]
                    }
                }
            },
            "required": ["entries"]
        }
    }
  }