Skip to content

renderFile of a WebC include within a draft fails on build #59

@darekkay

Description

@darekkay

Running eleventy fails when including a WebC file with renderFile in a file that is excluded from collections.

I have reproduced the issue within eleventy-base-blog by applying the following commit:

darekkay/eleventy-base-blog@f60f881

As the demo displays, the issue occurs when including a webc file using renderFile:

{% renderFile "_includes/webc/components/webc.webc" %}

It works fine when running npm run start (i.e. the dev server), by opening fifthpost:

rendered

But it fails with npm run build:

[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] 1. Having trouble rendering njk template ./content/blog/fifthpost.md (via TemplateContentRenderError)
[11ty] 2. (./content/blog/fifthpost.md)
[11ty]   EleventyShortcodeError: Error with Nunjucks shortcode `renderFile` (via Template render error)
[11ty] 3. Cannot read properties of undefined (reading 'url') (via Template render error)
[11ty]
[11ty] Original error stack trace: TypeError: Cannot read properties of undefined (reading 'url')
[11ty]     at Object.addContent (C:\eleventy-base-blog\node_modules\@11ty\eleventy-plugin-bundle\eleventy.shortcodes.js:24:39)
[11ty]     at Object.css (C:\eleventy-base-blog\node_modules\@11ty\eleventy\src\BenchmarkGroup.js:32:26)
[11ty]     at Object.<anonymous> (C:\eleventy-base-blog\node_modules\@11ty\eleventy-plugin-webc\src\eleventyWebcTemplate.js:132:37)
[11ty] Copied 1 file / Wrote 0 files in 0.46 seconds (v2.0.0)

The issue is "fixed" when the renderFile line is removed.

The issue does not happen when including a markdown file (as presented in the same demo).

Reproducible on:

  • Windows 10 / Node 18.8.0
  • macOS / Node 18.11.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions