Regarding the TOC problem, you were on the right track with using the {{% %}}
notation to call the shortcode, but there’s one piece missing. In the shortcode, you need to render .RawContent
not .Content
.
Assuming this structure:
content/
├── snippets/
│ ├── index.md
│ ├── snippet-1.md
│ └── snippet-2.md
└── _index.md
And this in your _index.md
page:
{{% include "snippet-1.md" %}}
{{% include "snippet-2.md" %}}
Then the TOC is properly generated with a shortcode like:
{{ with $path := .Get 0 }}
{{ with $.Page.GetPage "snippets" }}
{{ with .Resources.Get $path }}
{{ .RawContent }}
{{ else }}
{{ errorf "The %s shortcode was unable to get %s. See %s" $.Name $path $.Position }}
{{ end }}
{{ else }}
{{ errorf "The %s shortcode was unable to find the snippets page. See %s" $.Name $.Position }}
{{ end }}
{{ else }}
{{ errorf "The % shortcode requires a single positional parameter. See %s" .Name .Position }}
{{ end }}