MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / parseCustomTemplate

Function parseCustomTemplate

packages/shared-domain/src/template-files.ts:69–86  ·  view source on GitHub ↗
(raw: string, sourcePath: string)

Source from the content-addressed store, hash-verified

67
68/** Parse a raw custom-template file into a NoteTemplate. Never throws. */
69export function parseCustomTemplate(raw: string, sourcePath: string): NoteTemplate {
70 const { data, body } = parseFrontmatter(raw)
71 const stem = filenameStem(sourcePath)
72 const name = data.name?.trim() || stem
73 return {
74 id: `custom:${stem}`,
75 name,
76 description: data.description?.trim() ?? '',
77 category: normalizeCategory(data.category),
78 body,
79 titleTemplate: data.titleTemplate?.trim() || undefined,
80 targetFolder: normalizeTargetFolder(data.targetFolder),
81 targetSubpath: data.targetSubpath?.trim() || undefined,
82 builtin: false,
83 sourcePath,
84 builtinId: data.builtinId?.trim() || undefined
85 }
86}
87
88const CATEGORY_ORDER: TemplateCategory[] = ['Engineering', 'Personal', 'Custom']
89

Callers 2

store.tsFile · 0.90

Calls 4

parseFrontmatterFunction · 0.85
normalizeCategoryFunction · 0.85
normalizeTargetFolderFunction · 0.85
filenameStemFunction · 0.70

Tested by

no test coverage detected