Open JordanShurmer opened 3 years ago
Hi @JordanShurmer - thanks for your help/comments in my repo!
Eleventy doesn't have a content
variable available inside a content file. In a content file, it's undefined
: content
doesn't exist until a layout template has incoming content to process. If you've got ideas on how to handle this better, I'd love to hear how you're aiming to solve it. Thanks!
I have not put much thought into this bug.
It's not something I personally have a problem with, but recorded the issue so that it can be tracked and hopefully a solution can be reached.
If there is no content
available in the content file, perhaps documentation for other approaches is the best solution. For example, adding something like this to the READMEs: https://github.com/jdsteinbach/eleventy-plugin-toc/issues/21#issuecomment-780122410
Background
This comes from an issue in the upstream fork:
https://github.com/jdsteinbach/eleventy-plugin-toc/issues/21
Problem
Apparently, in certain situations the
content
is not coming through as String. The error that gets thrown is:The crux of the problem, in the words of @netmikey
Solution
Need to find out what kind of object
content
is when used in a content file. Then turn it into the expected string (if possible) before passing it to cheerio.