feat: dynamic custom frontmatter fields + CTF writeup template system
User requested dynamic (not static) fields for CTF writeup content organization. Changes: - DocumentMeta: removed typed CTF fields (event/challenge/category/difficulty/ points), replaced with single extraFields?: Record<string, string> - parseFile: any frontmatter key not in the STANDARD set becomes a dynamic extra field — fully content-driven, no code changes needed for new fields - stringifyFile: writes extraFields back to YAML frontmatter for round-trip stability - DocForm: '+ Add field' UI lets creators add ANY metadata key at create/edit time - API routes: splitPayload() auto-separates standard vs custom fields - Doc page: CustomFieldBadges dynamically renders any custom field with auto-styling for common CTF patterns (difficulty→color, points→badge) - Added db:migrate + db:push scripts; deploy workflow now runs migrations + reindexes content on every deploy - content/writeups/ctf/template/writeup-template.md (template) - content/writeups/ctf/defcon-quals-2024/pwn-100-ret2win-alignment.md (sample) - DB column extra_fields (jsonb) already applied to live DB
This commit is contained in:
@@ -14,14 +14,8 @@ export interface DocumentMeta {
|
||||
path: string; // relative path under content/
|
||||
createdAt: string; // ISO
|
||||
updatedAt: string; // ISO
|
||||
// CTF writeup metadata (optional — only set for writeups)
|
||||
event?: string;
|
||||
challenge?: string;
|
||||
category?: string;
|
||||
difficulty?: "easy" | "medium" | "hard";
|
||||
points?: number;
|
||||
// Dynamic custom frontmatter fields (serialized as-is to YAML frontmatter).
|
||||
// Allows content creators to add arbitrary metadata keys without code changes.
|
||||
// Dynamic custom frontmatter fields (e.g. CTF: event, challenge, category,
|
||||
// difficulty, points). Content creators add arbitrary key-value pairs.
|
||||
extraFields?: Record<string, string>;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user