Skip to content

Instantly share code, notes, and snippets.

@cshaa
Last active October 23, 2024 08:58
Show Gist options
  • Save cshaa/7e6844a161714229d5a7fccccd3e5136 to your computer and use it in GitHub Desktop.
Save cshaa/7e6844a161714229d5a7fccccd3e5136 to your computer and use it in GitHub Desktop.
Decap CMS – JSON Schema for config.yml
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"backend": {
"type": "object",
"properties": {
"name": { "type": "string" },
"repo": { "type": "string" },
"branch": { "type": "string" },
"api_root": { "type": "string" },
"commit_messages": {
"type": "object",
"properties": {
"create": { "type": "string" },
"update": { "type": "string" },
"delete": { "type": "string" },
"uploadMedia": { "type": "string" },
"deleteMedia": { "type": "string" },
"openAuthoring": { "type": "string" }
}
}
},
"required": ["name", "repo"]
},
"publish_mode": {
"type": "string",
"enum": ["simple", "editorial_workflow", ""]
},
"media_folder": { "type": "string" },
"public_folder": { "type": "string" },
"media_library": {
"type": "object",
"properties": {
"name": { "type": "string" },
"config": {
"type": "object"
}
},
"required": ["name"]
},
"site_url": { "type": "string", "format": "uri" },
"display_url": { "type": "string", "format": "uri" },
"logo_url": { "type": "string", "format": "uri" },
"locale": { "type": "string" },
"show_preview_links": { "type": "boolean" },
"search": { "type": "boolean" },
"slug": {
"type": "object",
"properties": {
"encoding": { "type": "string", "enum": ["unicode", "ascii"] },
"clean_accents": { "type": "boolean" },
"sanitize_replacement": { "type": "string" }
}
},
"collections": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"identifier_field": { "type": "string" },
"label": { "type": "string" },
"label_singular": { "type": "string" },
"description": { "type": "string" },
"files": { "type": "array" },
"folder": { "type": "string" },
"filter": { "type": "object" },
"create": { "type": "boolean" },
"publish": { "type": "boolean" },
"hide": { "type": "boolean" },
"delete": { "type": "boolean" },
"extension": { "type": "string" },
"format": {
"type": "string",
"enum": [
"yml",
"yaml",
"toml",
"json",
"md",
"markdown",
"html",
"frontmatter",
"yaml-frontmatter",
"toml-frontmatter",
"json-frontmatter"
]
},
"frontmatter_delimiter": {
"oneOf": [
{ "type": "string" },
{ "type": "array", "items": { "type": "string" } }
]
},
"slug": { "type": "string" },
"preview_path": { "type": "string" },
"preview_path_date_field": { "type": "string" },
"fields": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"label": { "type": "string" },
"widget": { "type": "string" },
"default": {},
"required": { "type": "boolean", "default": true },
"hint": { "type": "string" },
"pattern": {
"type": "array",
"items": [{ "type": "string" }, { "type": "string" }]
},
"comment": { "type": "string" }
},
"required": ["name", "widget"]
}
},
"editor": {
"type": "object",
"properties": {
"preview": { "type": "boolean" }
}
},
"summary": { "type": "string" },
"sortable_fields": { "type": "array", "items": { "type": "string" } },
"view_filters": { "type": "array", "items": { "type": "object" } },
"view_groups": { "type": "array", "items": { "type": "object" } }
},
"required": ["name", "fields"]
}
}
},
"required": ["backend", "media_folder", "collections"]
}
export interface Config {
backend: {
name: string;
repo: string;
branch?: string;
api_root?: string;
commit_messages?: {
create?: string;
update?: string;
delete?: string;
uploadMedia?: string;
deleteMedia?: string;
openAuthoring?: string;
[k: string]: unknown;
};
[k: string]: unknown;
};
publish_mode?: "simple" | "editorial_workflow" | "";
media_folder: string;
public_folder?: string;
media_library?: {
name: string;
config?: {
[k: string]: unknown;
};
[k: string]: unknown;
};
site_url?: string;
display_url?: string;
logo_url?: string;
locale?: string;
show_preview_links?: boolean;
search?: boolean;
slug?: {
encoding?: "unicode" | "ascii";
clean_accents?: boolean;
sanitize_replacement?: string;
[k: string]: unknown;
};
collections: {
name: string;
identifier_field?: string;
label?: string;
label_singular?: string;
description?: string;
files?: unknown[];
folder?: string;
filter?: {
[k: string]: unknown;
};
create?: boolean;
publish?: boolean;
hide?: boolean;
delete?: boolean;
extension?: string;
format?:
| "yml"
| "yaml"
| "toml"
| "json"
| "md"
| "markdown"
| "html"
| "frontmatter"
| "yaml-frontmatter"
| "toml-frontmatter"
| "json-frontmatter";
frontmatter_delimiter?: string | string[];
slug?: string;
preview_path?: string;
preview_path_date_field?: string;
fields: {
name: string;
label?: string;
widget: string;
default?: unknown;
required?: boolean;
hint?: string;
pattern?: [] | [string] | [string, string];
comment?: string;
[k: string]: unknown;
}[];
editor?: {
preview?: boolean;
[k: string]: unknown;
};
summary?: string;
sortable_fields?: string[];
view_filters?: {
[k: string]: unknown;
}[];
view_groups?: {
[k: string]: unknown;
}[];
[k: string]: unknown;
}[];
[k: string]: unknown;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment