{{ $hasHeaders := gt (len (findRE "<h\\d.*?>(.|\n)*?</h\\d>" .Content)) 0 }}
{{ if $hasHeaders }}
<aside class="mainTOC">
    <details {{ if $.Site.Data.config.openToc }}open {{ end }}>
        <summary>{{ i18n "toc" }}</summary>
        {{ .TableOfContents }}
    </details>
</aside>
{{end}}
