Object Oriented Thinking

by Tiago Jacinto
5
4
3
2
1
Score: 52/100

Description

The Object Oriented Thinking plugin introduces inheritance like behaviour to notes by allowing one note to extend another using frontmatter properties. It provides utility methods for querying and determining hierarchical relationships between notes, enabling advanced workflows where child notes can inherit attributes from parent notes. Developers can leverage these methods in Dataview queries or custom scripts to build dynamic, object-oriented structures within their vault. This makes it particularly useful for organising complex systems like task hierarchies, documentation, or knowledge bases.

Reviews

No reviews yet.

Stats

6
stars
463
downloads
0
forks
303
days
71
days
264
days
0
total PRs
0
open PRs
0
closed PRs
0
merged PRs
0
total issues
0
open issues
0
closed issues
0
commits

README file from

Github

Object Oriented Thinking

Add inheritance-like behavior to notes.

Usage

1. Extend

In a note's frontmatter, add the property (default: extends) with a link to the parent note:

---
extends: [[ParentNote]]
---

2. Query

Using utility methods: getObjectFileByPath(path).isDescendantOf(parentObjectFile)

Methods

Examples
const 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]))
oot.getObjectFileByPath(path: string): TFile & {isDescendantOf: (parentFile: TFile) => boolean} | null
Examples
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]),
);

Defining your own functions

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]))

Manually installing the plugin

  • Copy over main.js, styles.css, manifest.json to your vault VaultFolder/.obsidian/plugins/your-plugin-id/.