MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / updateDailyNoteFrontmatter

Function updateDailyNoteFrontmatter

src/utils/helpers.ts:971–996  ·  view source on GitHub ↗

* Updates daily note frontmatter while preserving body content

(
	app: App,
	dailyNote: TFile,
	frontmatter: DailyNoteFrontmatterWithTimeblocks,
	originalContent: string
)

Source from the content-addressed store, hash-verified

969 * Updates daily note frontmatter while preserving body content
970 */
971async 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

Callers 3

updateTimeblockTimesFunction · 0.85
addTimeblockToDailyNoteFunction · 0.85

Calls 2

stringifyYamlFunction · 0.90
modifyVaultFileFunction · 0.90

Tested by

no test coverage detected