<%* // People Template - Dynamically reads from fileClass schema // Single source of truth: Templates/fileClasses/people.md
const personName = await tp.system.prompt(“Person’s name:”); if (!personName) return;
// Rename file await tp.file.rename(personName);
// Get basic relationship type const relationshipTypes = [“friend”, “coworker”, “family”, “client”, “business”, “acquaintance”, “mentor”]; const selectedType = await tp.system.suggester( relationshipTypes, relationshipTypes, false, “Primary relationship:” );
// Read fileClass schema const fileClassPath = “Templates/fileClasses/people.md”; const fileClassContent = await app.vault.adapter.read(fileClassPath);
// Parse YAML frontmatter to get fields const yamlMatch = fileClassContent.match(/^---\n([\s\S]*?)\n---/); if (!yamlMatch) { new Notice(“Error: Could not parse fileClass schema”); return; }
// Extract field names from the fields array const fieldsSection = yamlMatch[1]; const fieldMatches = […fieldsSection.matchAll(/- name: ([a-z_]+)/g)]; const fields = fieldMatches.map(match ⇒ match[1]);
// Start frontmatter tR += ”---\n”; tR += “person: "" + personName + ""\n”; tR += “created: ” + tp.date.now(“YYYY-MM-DD”) + “\n”; tR += “tags:\n”; tR += ” - people\n”;
// Generate all fields from schema for (const fieldName of fields) { // Skip fields we already added if ([“person”, “created”, “tags”].includes(fieldName)) continue;
// Special handling for specific fields
if (fieldName === "interests") {
tR += "interests: []\n";
} else if (fieldName === "relationship_type" && selectedType) {
tR += "relationship_type:\n";
tR += " - " + selectedType + "\n";
} else if (fieldName === "relationship_type" && !selectedType) {
tR += "relationship_type:\n";
} else {
tR += fieldName + ": \n";
}
}
tR += ”---\n\n”; -%>
[[components/metabind-buttons-embed]]Quick Info
quick-info-display
Notes
= this.notes