3b7aafd56e
SteamWarCI Build successful
- Render frontmatter fields from content schemas - Add specialized selectors for events, images, and view config - Refresh the pages editor layout and tab bar
94 lines
3.7 KiB
TypeScript
94 lines
3.7 KiB
TypeScript
export type FrontmatterFieldKind = "string" | "text" | "number" | "boolean" | "date" | "string-array" | "reference" | "image" | "object";
|
|
|
|
export interface FrontmatterFieldSchema {
|
|
key: string;
|
|
label: string;
|
|
kind: FrontmatterFieldKind;
|
|
required?: boolean;
|
|
maxLength?: number;
|
|
collection?: string;
|
|
defaultValue?: unknown;
|
|
description?: string;
|
|
}
|
|
|
|
export interface FrontmatterCollectionSchema {
|
|
collection: string;
|
|
label: string;
|
|
fields: FrontmatterFieldSchema[];
|
|
}
|
|
|
|
export const markdownFrontmatterSchemas: Record<string, FrontmatterCollectionSchema> = {
|
|
pages: {
|
|
collection: "pages",
|
|
label: "Pages",
|
|
fields: [
|
|
{ key: "title", label: "Title", kind: "string", required: true, maxLength: 80 },
|
|
{ key: "description", label: "Description", kind: "text", required: true, maxLength: 120 },
|
|
{ key: "image", label: "Image", kind: "image" },
|
|
{ key: "slugs", label: "Slugs", kind: "object", description: "Language to slug mapping, for example { de: 'seite', en: 'page' }." },
|
|
],
|
|
},
|
|
help: {
|
|
collection: "help",
|
|
label: "Help",
|
|
fields: [
|
|
{ key: "title", label: "Title", kind: "string", required: true, maxLength: 80 },
|
|
{ key: "description", label: "Description", kind: "text", required: true, maxLength: 120 },
|
|
{ key: "tags", label: "Tags", kind: "string-array", required: true },
|
|
{ key: "related", label: "Related", kind: "string-array", collection: "help", description: "IDs of related help pages." },
|
|
],
|
|
},
|
|
rules: {
|
|
collection: "rules",
|
|
label: "Rules",
|
|
fields: [
|
|
{ key: "translationKey", label: "Translation key", kind: "string", required: true },
|
|
{ key: "mode", label: "Mode", kind: "reference", collection: "modes" },
|
|
],
|
|
},
|
|
announcements: {
|
|
collection: "announcements",
|
|
label: "Announcements",
|
|
fields: [
|
|
{ key: "title", label: "Title", kind: "string", required: true },
|
|
{ key: "description", label: "Description", kind: "text", required: true },
|
|
{ key: "author", label: "Author", kind: "string" },
|
|
{ key: "image", label: "Image", kind: "image" },
|
|
{ key: "tags", label: "Tags", kind: "string-array", required: true },
|
|
{ key: "created", label: "Created", kind: "date", required: true },
|
|
{ key: "key", label: "Key", kind: "string", required: true },
|
|
],
|
|
},
|
|
events: {
|
|
collection: "events",
|
|
label: "Events",
|
|
fields: [
|
|
{ key: "eventId", label: "Event ID", kind: "number", required: true },
|
|
{ key: "image", label: "Image", kind: "image" },
|
|
{ key: "mode", label: "Mode", kind: "reference", collection: "modes" },
|
|
{ key: "hideTeamSize", label: "Hide team size", kind: "boolean", defaultValue: false },
|
|
{ key: "verantwortlich", label: "Verantwortlich", kind: "string" },
|
|
{ key: "viewConfig", label: "View config", kind: "object" },
|
|
],
|
|
},
|
|
docs: {
|
|
collection: "docs",
|
|
label: "Docs",
|
|
fields: [
|
|
{ key: "title", label: "Title", kind: "string", required: true },
|
|
{ key: "description", label: "Description", kind: "text" },
|
|
{ key: "sidebar", label: "Sidebar", kind: "object" },
|
|
{ key: "template", label: "Template", kind: "string" },
|
|
{ key: "draft", label: "Draft", kind: "boolean" },
|
|
],
|
|
},
|
|
};
|
|
|
|
export function getMarkdownFrontmatterSchema(collection: string | undefined): FrontmatterCollectionSchema | undefined {
|
|
if (!collection) {
|
|
return undefined;
|
|
}
|
|
|
|
return markdownFrontmatterSchemas[collection];
|
|
}
|