TOC not complete when using Readfile
I tried scanning the issues so hopefully this isn't a repeat.
I use readfile for different purposes (including snippets of the same code into multiple pages, etc), and one thing I've noticed is if headers are in the readfile, then the TOC isn't generating those links.
For example, if we have this:
## Introduction
This will help you install this program.
{{< readfile "/includes/warning_notice.md" >}}
and if warning_notice.md contains:
### General Warnings
Hi! Don't forget if you install this program then press G, your computer will explode!
The TOC will be:
## Introduction
I may have to revamp the toc.html shortcode myself, but has anything else looked into this, and is there a flag we can add to the readfile shortcode (or the toc?) to include the headers from readfile command into the toc?
~~Additional note: someone may note that I could use:
{{% readfile "/includes/warning_notice.md" %}}
However, when I do I get:
<h3>General Warnings</h3>
Hi! Don't forget if you install this program then press G, your computer will explode!
The first line is always rendered oddly, and then every other line after that is properly rendered.~~
UPDATE: This is fixed with the current version of Docsy. The other issue of readfile not being included in TOC parsing remains.
I want to emphasize the importance of this feature. I also need to use the readfile shortcode for different reuse purposes. and I can confirm that Docsy does not show any right-hand nav if the file has headers in there.
AFAIK, that's just the way Hugo works. This recent thread on the Hugo forum covers a similar issue, but I think that the proposed solution might have some side-effects when there are other shortcodes in the included file (not sure though). Another possible solution is to use a custom ToC sidebar rendered from JS, because that runs on the client side when all the headers are already available.
Explanation: https://discourse.gohugo.io/t/42747/2
Other approaches to creating TOC: https://discourse.gohugo.io/t/42747/7