Cool to hear. I want to set up a page TOC as nested lists, and while there are client-side methods, I thought I'd like to do it as a Resource so that I can manage the styling etc with Webstudio.
While working on that, I realized I already have Typesense docsearch (similar to Algolia), which scrapes the site for full site search.
I can query Typesense API to return JSON with a flat array of elements on a given page, and in that flat array, there are nodes like:
"document": {
"anchor": "heading-2-title",
"hierarchy": {
"lvl0": "Heading 1 Title",
"lvl1": "Heading 2 Title",
"lvl2": null,
"lvl3": null,
"lvl4": null,
"lvl5": null,
"lvl6": null
},
...
which refers to the
<h2>
in:
<h1 id="heading-1-title">Heading 1 Title</h1>
some text....
<h2 id="heading-2-title">Heading 2 Title</h2>
some more text...
So the info about the heading hierarchies is there, but it's all in one flat array of every heading, no matter h1, h2, h3 etc. So I need to loop through it and produce nested arrays, which then I wanted to provide as a variable to a Collection within a List (or nested collections within lists, or something...)