fix: handle non-string outputPath in html-transformer override

outputPath can be `false` for pages without output. Optional chaining
(?.) only guards null/undefined, not booleans — use typeof check instead.

Confab-Link: http://localhost:8080/sessions/0b241cd6-aff2-4fec-853c-2b5a61e61946
This commit is contained in:
Ricardo
2026-03-10 16:19:59 +01:00
parent ea7433852d
commit 1cdc4b89a7

View File

@@ -342,7 +342,7 @@ export default function (eleventyConfig) {
// overwrites via addTransform) with a pre-check that avoids the full PostHTML
// parse/serialize cycle (~3ms/page) for image-free pages.
eleventyConfig.addTransform("@11ty/eleventy/html-transformer", async function(content) {
if (this.outputPath?.endsWith(".html") && !content.includes("<img")) {
if (typeof this.outputPath === "string" && this.outputPath.endsWith(".html") && !content.includes("<img")) {
// Safety: if URL transform callbacks exist (they modify <a>, <link>, etc.)
// we must still run the full pipeline even without images.
const hasUrlCallbacks = eleventyConfig.htmlTransformer.getCallbacks("html", this).length > 0;