Programmatically build TOC

I’m wondering is it possible to add items to the table of contents programatically, or is it only built from Markdown headers?

I’m doing some looping through data in my page and would like to add a TOC entry for each block, but I haven’t figured out how to do that. Outputting H2s through a template tag doesn’t do it.

Is this a question about Observable Framework? If so, please ask on our GitHub Discussions. Thank you.

1 Like