Something went wrong. Try again.
A CLI for publishing standard.site documents to ATProto
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899import schema from "../../../sequoia.schema.json" with { type: "json" };
type PropertyInfo = { path: string; type: string; required: boolean; default?: string | number | boolean; description?: string;};
function extractProperties( properties: Record<string, unknown>, required: string[], parentPath: string, parentRequired: boolean, result: PropertyInfo[],): void { for (const [key, value] of Object.entries(properties)) { const prop = value as Record<string, unknown>; const fullPath = parentPath ? `${parentPath}.${key}` : key; const isRequired = parentRequired && required.includes(key);
if (prop.properties) { extractProperties( prop.properties as Record<string, unknown>, (prop.required as string[]) || [], fullPath, isRequired, result, ); } else { result.push({ path: fullPath, type: prop.type, required: isRequired, default: prop.default, description: prop.description, } as PropertyInfo); } }}
export default function ConfigTable() { const rows: PropertyInfo[] = []; extractProperties( schema.properties as Record<string, unknown>, schema.required as string[], "", true, rows, ); // Show $schema, then required fields alphabetically, then optional fields alphabetically. rows.sort( (a, b) => Number(b.path === "$schema") - Number(a.path === "$schema") || Number(b.required) - Number(a.required) || a.path.localeCompare(b.path), );
return ( <table className="vocs_Table"> <thead> <tr className="vocs_TableRow"> <th className="vocs_TableHeader">Field</th> <th className="vocs_TableHeader">Type</th> <th className="vocs_TableHeader">Required</th> <th className="vocs_TableHeader">Default</th> <th className="vocs_TableHeader">Description</th> </tr> </thead> <tbody> {rows.map((row) => ( <tr key={row.path} className="vocs_TableRow"> <td className="vocs_TableCell"> <code className="vocs_Code">{row.path}</code> </td> <td className="vocs_TableCell"> <code className="vocs_Code">{row.type}</code> </td> <td className="vocs_TableCell">{row.required ? "Yes" : ""}</td> <td className="vocs_TableCell"> {row.default === undefined ? ( "" ) : ( <code className="vocs_Code"> {typeof row.default === "string" ? `"${row.default}"` : `${row.default}`} </code> )} </td> <td className="vocs_TableCell">{row.description || ""}</td> </tr> ))} </tbody> </table> );}