tiagojacinto541 downloadsAdd inheritance-like behavior to notes.
Add inheritance-like behavior to notes.
In a note's frontmatter, add the property (default: extends) with a link to the parent note:
---
extends: [[ParentNote]]
---
Using utility methods: getObjectFileByPath(path).isDescendantOf(parentObjectFile)
[[${string}]]): TFile & {isDescendantOf: (parentFile: TFile) => boolean} | nullconst taskObjectFile = oot.getObjectFileByLink("[[Task]]")
dv.table(["File"], dv.pages().where(page => {
const pageObjectFile = oot.getObjectFileByPath(page.file.path)
return pageObjectFile?.isDescendantOf(taskObjectFile)
}).map(p => [p.file.link]))
const currentObjectFile = oot.getObjectFileByPath(dv.current().file.path);
dv.table(
['File'],
dv
.pages()
.where((page) => {
const pageObjectFile = oot.getObjectFileByPath(page.file.path);
return pageObjectFile?.isDescendantOf(currentObjectFile);
})
.map((p) => [p.file.link]),
);
You can define your own functions like this or use javascript loader plugins like CustomJS:
const isDescendantOf = (parentObjectFile) => (page) => oot.getObjectFileByPath(page.file.path)?.isDescendantOf(parentObjectFile) ?? false
const taskObjectFile = oot.getObjectFileByLink("[[Inbox/Task|Task]]")
dv.table(["File"], dv.pages().where(isDescendantOf(taskObjectFile)).map(p => [p.file.link]))
main.js, styles.css, manifest.json to your vault VaultFolder/.obsidian/plugins/your-plugin-id/.