MCPcopy Create free account
hub / github.com/chhoumann/quickadd / resolveActiveNoteFieldDefault

Function resolveActiveNoteFieldDefault

src/utils/activeNoteFieldDefault.ts:59–71  ·  view source on GitHub ↗
(
	app: App,
	activeFile: TFile | null | undefined,
	fieldName: string,
)

Source from the content-addressed store, hash-verified

57 * {@link resolveFieldDefaultFromFrontmatter}). Read-only: it never mutates a file.
58 */
59export function resolveActiveNoteFieldDefault(
60 app: App,
61 activeFile: TFile | null | undefined,
62 fieldName: string,
63): string | string[] | null {
64 // Only Markdown notes carry frontmatter properties; a non-md active file (or
65 // no active file) means "no active-derived default", matching the issue's
66 // "fall back to normal {{FIELD:project}} behavior" rule.
67 if (!activeFile || activeFile.extension !== "md") return null;
68
69 const frontmatter = app.metadataCache.getFileCache(activeFile)?.frontmatter;
70 return resolveFieldDefaultFromFrontmatter(frontmatter, fieldName);
71}
72
73/**
74 * Converts a single frontmatter value into a default string when it is a usable

Callers 3

suggestForFieldMethod · 0.90
suggestForFieldMethod · 0.90

Calls 1

Tested by

no test coverage detected