I have an obsidian.md vault with notes and I want to display them in a webpage with a specific order/hierarchy. I want to do this without hardcoding anything in the html file itself so when I found out about frontmatter I thought it would be the perfect way to achieve this by assigning a weight and slug parameter to each note in their frontmatter. However it got complicated when I added subdirectories with unknown depth. This is how I'm imagining it: (this is an example vault)
path local weight global weight uri
Introduction.md 1 1 intro
Programmming/ 2 2 prog
Computer basics.md 1 2.1 prog/c-basics
Compiled vs Interpreted.md 2 2.2 prog/com-vs-int
Python/ 3 2.3 prog/pyt
Five minute crash course.md 1 2.3.1 prog/pyt/course
.meta.md
Rust/ 4 2.4 prog/rust/
Introduction.md 1 2.4.1 prog/rust/intro
Borrow checker.md 2 2.4.2 prog/rust/borrow
Lifetimes.md 3 2.4.3 prog/rust/lifetime
.meta.md
Six figure job guide.md 5 2.5 prog/six-fig
.meta.md
CyberSecurity/ 3 3 cyber
Introduction.md 1 3.1 cyber/intro.md
Virtual machines.md 2 3.2 cyber/vm.md
Kali Linux.md 3 3.3 cyber/kali.md
.meta.md
Other cool stuff.md 4 4 others.md
So with each note having their own slug and "local weight", a global weight is created based on the weight of the note and the subdirectories they're in. A .meta.md file (random name I came up with) in each subdirectory assigns that subdirectory its weight, slug and title (so that the displayed name can be independent of that actual folder name). The uri is constructed from the slug of each subdirectory and the note. Ultimately it'll look like sections and subsections in a textbook.
I am using Rust + Axum for the web server. On initialization, the vault directory is scanned with for entry in glob::glob("./vault/**/*.md") (which can be in a random order) and then sorted based on the global weights to create this hierarchy. When the webpage is requested, it iterates over the hierarchy and generates the ordered list html code with links to the markdown files.
I know this is a binary tree problem and I don't really have any exposure to data structures and algorithms (DSA?). I'm not a CS student, I just do programming for fun. Although I gave this a many tries, I just ended up completely lost and confused. I would really appreciate any help with this or maybe a better way to achieve this!