I try to insert all inlinks to a note (“backlinks”) in a templater template but without succes. (And I would like to similarly be able to extract other metadata from files for other purposes)
By googling and searching through this forum it seems that “this.app.metadataCache” is the way to go.
I am able to insert frontmatter data such as tags or titles from other note with:
<%*
var get_frontmatter = this.app.metadataCache.getFileCache(tp.file.find_tfile("CurrentNoteName"))
_%>
<% get_frontmatter.frontmatter.title %>
… or from current note with:
<%*
var get_frontmatter = this.app.metadataCache.getFileCache(currentFile)
_%>
<% get_frontmatter.frontmatter.title %>
I see the command “const backlinks = this.app.metadataCache.getBacklinksForFile(currentFile)?.data” mentioned in a few forum posts but am unable to use it to insert all inlinks. This only gets an error:
<%*
var get_backlinks = this.app.metadataCache.getBacklinksForFile(currentFile)
_%>
<% get_backlinks %>
Anyone able to point me in the right direction? Appreciated!
In some cases I’ve used dataview to get the data within a template, and then use for example dv.markdownList() appended to the tR to make it a static result.