How to check that there is a path leading to all notes

Hi all, this is my first question on this forum, so please correct me if I do wrong.

I have been using obsidian since several months, and I use it also to edit a project documentation repository.
This means that other project users will read the content I write in a gitlab.

In order to ensure that they can find all notes I wrote. I would like to ensure there is a path throught links from the documentation homepage to all notes.

In order to do this I started using graph view and fight against orpheans… but it does not ensure me that a group of notes is not disconnected from homepage.

Do you have any suggestion on how to make this quality check?

I made a small proof of concept. First I installed the RunJS extension. Then I created a Scripts_RunJS folder in my vault. I created a checkOrphans.js file inside that folder and put the following code in it.

const rootFile = "Home.md"
const allFiles = new Set(app.vault.getMarkdownFiles().map(x => x.path))
const connectedFiles = new Set()
const toVisit = new Set()

toVisit.add(rootFile)

while (toVisit.size > 0) {
    const cursor = toVisit.values().next().value

    connectedFiles.add(cursor)
    toVisit.delete(cursor)

    const outgoingLinks = app.metadataCache.resolvedLinks[cursor]
    for (const link in outgoingLinks) {
        if (!connectedFiles.has(link)) {
            toVisit.add(link)
        }
    }
}

const orphans = allFiles
for (const file of connectedFiles) {
    orphans.delete(file)
}

console.log(orphans)

Then, I can click on that script through the RunJS extension to execute it. When the script is done, it prints out a list of non-connected files in the developer console. You can open the developer console in the View >> Toggle Developer Tools menu.

This is a bit janky, someone would need to wrap it up in an extension or something!

Hope its useful

EDIT: You do need to change the value of rootFile to the index you want to start from.

Hi david,
Thanks for your reply and thanks for making me discovering runjs plugin, this offers me a lot of possibilities.
I will play a little bit with your script and improve it, will post a v2 here when happy with it.
Best regards,Nicolas

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.