How could I automatically generate tree views/collapsible lists from Typst lists?

To expand a bit more, I imagine I need some sort of recursive wrapper around my notes-as-typst-list that somehow “unpacks” the list recursively, and inserts the relevant HTML for every item…