Is there any way to get an array of the anchors (with hrefs if possible) on a page?

I’m making a documentation site where some docs have sections (perhaps usage, specifics, whatever) and I’d like to programmatically add those sections (indicated solely by their anchor tags and an href beginning with #) to my treemenu.php snippet.

I’d create a custom field method and inside this method use some regex voodoo to find the anchors and add them to an array.

Having said that, how are these sections added to a page? In a text block?

in the kirby editor plugin, through a custom “section header” block…

Ah, then that’s even easier because you can filter these blocks.

aHA tysm