I have a property named related
where i link all sorts of notes or links. I created a template which adds the parent of this note as a related link.
Here’s how it appears for me:
---
created: 2024-10-28
related:
- "[[Video Encoding]]"
- other related things
---
And here’s the template:
<%*
const propertyName = "related"
// get path (relative to vault) for current note
const notePath = tp.file.path(relative=true)
// get Obsidian.TAbstractFile for current note
const tFile = tp.app.vault.getAbstractFileByPath(notePath);
if(!tFile.parent?.isRoot()) {
const parentName = tFile.parent.name
const parentLink = `[[${parentName}]]`
tp.app.fileManager.processFrontMatter(tFile, frontmatter => {
if(!frontmatter[propertyName].contains(parentLink)) {
frontmatter[propertyName].push(parentLink)
}
})
}
%>