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

Method resolveTemplateFile

src/services/TaskService.ts:384–414  ·  view source on GitHub ↗
(templateReference: string, sourcePath: string)

Source from the content-addressed store, hash-verified

382 }
383
384 private resolveTemplateFile(templateReference: string, sourcePath: string) {
385 const linkPath = parseLinkToPath(templateReference).trim();
386 if (!linkPath) {
387 return null;
388 }
389
390 const resolvedFile =
391 this.plugin.app.metadataCache.getFirstLinkpathDest?.(linkPath, sourcePath) ??
392 this.plugin.app.metadataCache.getFirstLinkpathDest?.(
393 linkPath.replace(/\.md$/i, ""),
394 sourcePath
395 ) ??
396 this.plugin.app.metadataCache.getFirstLinkpathDest?.(linkPath, "");
397 if (resolvedFile instanceof TFile) {
398 return resolvedFile;
399 }
400
401 const normalizedPath = normalizePath(linkPath);
402 const candidatePaths = /\.md$/i.test(normalizedPath)
403 ? [normalizedPath]
404 : [`${normalizedPath}.md`, normalizedPath];
405
406 for (const candidatePath of candidatePaths) {
407 const file = this.plugin.app.vault.getAbstractFileByPath(candidatePath);
408 if (file instanceof TFile) {
409 return file;
410 }
411 }
412
413 return null;
414 }
415
416 private buildOccurrenceTemplateData(
417 occurrenceTask: TaskInfo,

Callers 1

Calls 3

parseLinkToPathFunction · 0.90
normalizePathFunction · 0.90
getAbstractFileByPathMethod · 0.80

Tested by

no test coverage detected