Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support usage in a content template #4

Open
JordanShurmer opened this issue Feb 20, 2021 · 2 comments
Open

Support usage in a content template #4

JordanShurmer opened this issue Feb 20, 2021 · 2 comments

Comments

@JordanShurmer
Copy link
Owner

JordanShurmer commented Feb 20, 2021

Background

This comes from an issue in the upstream fork:

jdsteinbach#21

Problem

Apparently, in certain situations the content is not coming through as String. The error that gets thrown is:

`Error` was thrown:
    Error: cheerio.load() expects a string

The crux of the problem, in the words of @netmikey

I found out that this happens when you try to use content on a content template itself. I guess you have to use this outside the content, e.g. on the layout template.

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.

@jdsteinbach
Copy link

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!

@JordanShurmer
Copy link
Owner Author

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: jdsteinbach#21 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants