Table of contents not generated with Asciidoctor documents as source

Problem
When building a site using .adoc (Asciidoctor) documents as source, {{ .TableOfContents }} is not generated, unlike what happens with .md (Markdown) files.

single.html

        <article class="docpage__container">
            <aside class="docpage__sidenav">
                {{ partial "sidenav" . }}
            </aside>
            <article class="docpage__content">
                {{ partial "breadcrumb" . }}
                <header class="docpage__title"><h1>{{ .Title }}</h1></header>
                {{ partial "document-meta" . }}
                {{ .Content }}
            </article>
            <aside class="docpage__toc">
                {{ .TableOfContents }}
            </aside>
        </div>        
    {{ end }} 

Expected behavior
Hugo runs asciidoc when .adoc documents are in the content folder. The output has valid heading tags (<h1>, <h2>, etc.), so a table of content should be generated as it happens with .md files.

How to reproduce

  1. Put an .adoc file with Asciidoctor headings in the content folder (e.g. = Heading 1, == Heading 2).
  2. Build the docs or run the server locally.

Workaround
As a workaround, I generated the Table of contents through Asciidoctor by adding :toc: in the document, but that creates a div inside the article, not in the aside that contains the ToC. Our custom theme uses flex to arrange the ToC, so I use JS in the footer to move the div outside of its parent…

  if (document.getElementsByClassName('toc')[0] !== undefined) {
    document.getElementsByClassName('docpage__toc')[0].append(document.getElementsByClassName('toc')[0])
  }
</script>

Not quite elegant. :-/

Found a related issue, still open:

Will comment there…