( app: App, activeFile: TFile | null | undefined, fieldName: string, )
| 57 | * {@link resolveFieldDefaultFromFrontmatter}). Read-only: it never mutates a file. |
| 58 | */ |
| 59 | export 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 |
no test coverage detected