* Updates daily note frontmatter while preserving body content
( app: App, dailyNote: TFile, frontmatter: DailyNoteFrontmatterWithTimeblocks, originalContent: string )
| 969 | * Updates daily note frontmatter while preserving body content |
| 970 | */ |
| 971 | async function updateDailyNoteFrontmatter( |
| 972 | app: App, |
| 973 | dailyNote: TFile, |
| 974 | frontmatter: DailyNoteFrontmatterWithTimeblocks, |
| 975 | originalContent: string |
| 976 | ): Promise<void> { |
| 977 | // Get body content (everything after frontmatter) |
| 978 | let bodyContent = originalContent; |
| 979 | if (originalContent.startsWith("---")) { |
| 980 | const endOfFrontmatter = originalContent.indexOf("---", 3); |
| 981 | if (endOfFrontmatter !== -1) { |
| 982 | bodyContent = originalContent.substring(endOfFrontmatter + 3); |
| 983 | } |
| 984 | } |
| 985 | |
| 986 | // Convert frontmatter back to YAML |
| 987 | const frontmatterText = stringifyYaml(frontmatter); |
| 988 | |
| 989 | // Reconstruct file content |
| 990 | const newContent = `---\n${frontmatterText}---${bodyContent}`; |
| 991 | |
| 992 | // Write back to file |
| 993 | await modifyVaultFile(app, dailyNote, newContent); |
| 994 | |
| 995 | // Native metadata cache will automatically update |
| 996 | } |
| 997 | |
| 998 | /** |
| 999 | * Filters out empty or whitespace-only project strings |
no test coverage detected