This fabulous and exactly what I was looking for. I seems to solve this issue
Why not submit this to Discourse to include it as an official plug-in or feature? It could be included in the composer/editor toolbar to automatically insert a TOC in the post.