TOC before first h2?

Hello,

I’m trying to mimik Mediawiki’s TOC, which shows only before the first h2.

Is there a way to select what {{.content }} displays?

I tried this hack

{{ $body := replace .Content .Summary "" }}
{{ $body | safeHTML }}

But it didn’t work. The entire body gets printed.

For future reference, this is the solution:

{{ .Summary }}

{{ .TableOfContents }}

{{ $body := replace .Content .Summary "" }}

{{ $body | safeHTML }}

Don’t forget to add <!-- more --> to your content.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.