Table of Contents for a book

I’m trying to write a book. I want an automatically-generated table of contents.

Does something like this already exist, am I just using the wrong search phrases?

I’ve skimmed the Longform docs, but don’t see what I think I want.

I’m using Excalidraw a lot and lots of text. I think that I should be able to export the whole thing as PDF. The only thing missing is a table of content

You should be able to solve for that using Dataview. This article explains one way to do it. If you use folders, you can use a plugin like Waypoint to automate this for you.